diff --git a/360/fonts.cpp b/360/fonts.cpp index 2cd55da47c..61fb1b3441 100644 --- a/360/fonts.cpp +++ b/360/fonts.cpp @@ -16,7 +16,6 @@ #define NONET #include -#include #include "xdk360_video.h" #include "fonts.h" #include "../general.h" @@ -24,6 +23,254 @@ static video_console_t video_console; static xdk360_video_font_t m_Font; +static PackedResource m_xprResource; + +#define CALCFONTFILEHEADERSIZE(x) ( sizeof(unsigned long) + (sizeof(float)* 4) + sizeof(unsigned short) + (sizeof(wchar_t)*(x)) ) +#define FONTFILEVERSION 5 + +typedef struct { + 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. +} FontFileHeaderImage_t; + +// Font strike array. Immediately follows the FontFileHeaderImage_t +// structure image + +typedef struct { + 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; + +static const char g_strFontShader[] = + "struct VS_IN\n" + "{\n" + "float2 Pos : POSITION;\n" + "float2 Tex : TEXCOORD0;\n" + "};\n" + "struct VS_OUT\n" + "{\n" + "float4 Position : POSITION;\n" + "float2 TexCoord0 : TEXCOORD0;\n" + "};\n" + "uniform float4 Color : register(c1);\n" + "uniform float2 TexScale : register(c2);\n" + "sampler FontTexture : register(s0);\n" + "VS_OUT main_vertex( 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.TexCoord0.x = In.Tex.x * TexScale.x;\n" + "Out.TexCoord0.y = In.Tex.y * TexScale.y;\n" + "return Out;\n" + "}\n" + "float4 main_fragment( VS_OUT In ) : COLOR0\n" + "{\n" + "float4 FontTexel = tex2D( FontTexture, In.TexCoord0 );\n" + "return FontTexel;\n" + "}\n"; + +typedef struct { + D3DVertexDeclaration* m_pFontVertexDecl; // Shared vertex buffer + D3DVertexShader* m_pFontVertexShader; // Created vertex shader + D3DPixelShader* m_pFontPixelShader; // Created pixel shader +} Font_Locals_t; + +// All elements are defaulted to NULL +static Font_Locals_t s_FontLocals; // Global static instance + +static void xdk360_video_font_draw_text(xdk360_video_font_t * font, + float fOriginX, float fOriginY, unsigned long dwColor, + 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] = ( ( 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 + xdk360_video_font_begin(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; + + // 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(pVertex)[2] = (tu1<<16)|tv1; // Merged using big endian rules + reinterpret_cast(pVertex)[3] = dwChannelSelector; + pVertex[4] = X2; + pVertex[5] = Y2; + reinterpret_cast(pVertex)[6] = (tu2<<16)|tv1; // Merged using big endian rules + reinterpret_cast(pVertex)[7] = dwChannelSelector; + pVertex[8] = X3; + pVertex[9] = Y3; + reinterpret_cast(pVertex)[10] = (tu2<<16)|tv2; // Merged using big endian rules + reinterpret_cast(pVertex)[11] = dwChannelSelector; + pVertex[12] = X4; + pVertex[13] = Y4; + reinterpret_cast(pVertex)[14] = (tu1<<16)|tv2; // Merged using big endian rules + reinterpret_cast(pVertex)[15] = dwChannelSelector; + 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 ) + { + 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 + D3DDevice_EndVertices(pd3dDevice); + + // Undo window offsets + font->m_fCursorX -= Winx; + font->m_fCursorY -= Winy; + + // Call End() to complete the begin/end pair for drawing text + xdk360_video_font_end(font); +} + void xdk360_console_draw(void) { xdk360_video_t *vid = (xdk360_video_t*)driver.video_data; @@ -51,274 +298,72 @@ void xdk360_console_draw(void) xdk360_video_font_end(&m_Font); } -HRESULT xdk360_console_init( LPCSTR strFontFileName, unsigned long colBackColor, - unsigned long colTextColor) +static void xdk360_video_font_get_text_width(xdk360_video_font_t * font, const wchar_t * strText, float * pWidth, float * pHeight) { - xdk360_video_t *vid = (xdk360_video_t*)driver.video_data; - D3DDevice *m_pd3dDevice = vid->d3d_render_device; + // Set default text extent in output parameters + int iWidth = 0; + float fHeight = 0.0f; - video_console.first_message = true; - video_console.m_Buffer = NULL; - video_console.m_Lines = NULL; - video_console.m_nScrollOffset = 0; + if( strText ) + { + // Initialize counters that keep track of text extent + int ix = 0; + float fy = font->m_fFontHeight; // One character high to start + if( fy > fHeight ) + fHeight = fy; - // Calculate the safe area - unsigned int uiSafeAreaPct = vid->video_mode.fIsHiDef ? SAFE_AREA_PCT_HDTV - : SAFE_AREA_PCT_4x3; + // Loop through each character and update text extent + unsigned long letter; + while( (letter = *strText) != 0 ) + { + ++strText; - video_console.m_cxSafeArea = ( vid->d3dpp.BackBufferWidth * uiSafeAreaPct ) / 100; - video_console.m_cySafeArea = ( vid->d3dpp.BackBufferHeight * uiSafeAreaPct ) / 100; + // Handle newline character + if (letter == L'\n') + break; - video_console.m_cxSafeAreaOffset = ( vid->d3dpp.BackBufferWidth - video_console.m_cxSafeArea ) / 2; - video_console.m_cySafeAreaOffset = ( vid->d3dpp.BackBufferHeight - video_console.m_cySafeArea ) / 2; + // Handle carriage return characters by ignoring them. This helps when + // displaying text from a file. + if( letter == L'\r' ) + continue; - // Create the font - HRESULT hr = xdk360_video_font_init(&m_Font, strFontFileName ); - if( FAILED( hr ) ) - { - RARCH_ERR( "Could not create font.\n" ); - return -1; - } + // Translate unprintable characters + const GLYPH_ATTR* pGlyph; + + if( letter > font->m_cMaxGlyph ) + letter = 0; // Out of bounds? + else + letter = font->m_TranslatorTable[letter]; // Remap ASCII to glyph - // Save the colors - video_console.m_colBackColor = colBackColor; - video_console.m_colTextColor = colTextColor; + pGlyph = &font->m_Glyphs[letter]; // Get the requested glyph - // Calculate the number of lines on the screen - float fCharWidth, fCharHeight; - xdk360_video_font_get_text_width(&m_Font, L"i", &fCharWidth, &fCharHeight, FALSE); + // Get text extent for this character's glyph + ix += pGlyph->wOffset; + ix += pGlyph->wAdvance; - video_console.m_cScreenHeight = (unsigned int)( video_console.m_cySafeArea / fCharHeight ); - video_console.m_cScreenWidth = (unsigned int)( video_console.m_cxSafeArea / fCharWidth ); + // Since the x widened, test against the x extent - video_console.m_cScreenHeightVirtual = video_console.m_cScreenHeight; + if( ix > iWidth ) + iWidth = ix; + } + } - video_console.m_fLineHeight = fCharHeight; + float fWidth = (float)iWidth; + fHeight *= font->m_fYScaleFactor; // Apply the scale factor to the result + *pHeight = fHeight; // Store the final results - // Allocate memory to hold the lines - video_console.m_Buffer = new wchar_t[ video_console.m_cScreenHeightVirtual * ( video_console.m_cScreenWidth + 1 ) ]; - video_console.m_Lines = new wchar_t *[ video_console.m_cScreenHeightVirtual ]; - - // Set the line pointers as indexes into the buffer - for( unsigned int i = 0; i < video_console.m_cScreenHeightVirtual; i++ ) - video_console.m_Lines[ i ] = video_console.m_Buffer + ( video_console.m_cScreenWidth + 1 ) * i; - - video_console.m_nCurLine = 0; - video_console.m_cCurLineLength = 0; - memset( video_console.m_Buffer, 0, video_console.m_cScreenHeightVirtual * ( video_console.m_cScreenWidth + 1 ) * sizeof( wchar_t ) ); - xdk360_console_draw(); - - return hr; + fWidth *= font->m_fXScaleFactor; + *pWidth = fWidth; } -void xdk360_console_deinit() -{ - // Delete the memory we've allocated - if(video_console.m_Lines) - { - delete[] video_console.m_Lines; - video_console.m_Lines = NULL; - } - - if(video_console.m_Buffer) - { - delete[] video_console.m_Buffer; - video_console.m_Buffer = NULL; - } - - // Destroy the font - xdk360_video_font_deinit(&m_Font); -} - -void xdk360_console_add( wchar_t wch ) -{ - // If this is a newline, just increment lines and move on - if( wch == L'\n' ) - { - video_console.m_nCurLine = ( video_console.m_nCurLine + 1 ) - % video_console.m_cScreenHeightVirtual; - video_console.m_cCurLineLength = 0; - memset(video_console.m_Lines[video_console.m_nCurLine], 0, - ( video_console.m_cScreenWidth + 1 ) * sizeof( wchar_t ) ); - return; - } - - int bIncrementLine = FALSE; // Whether to wrap to the next line - - if( video_console.m_cCurLineLength == video_console.m_cScreenWidth ) - bIncrementLine = TRUE; - else - { - // Try to append the character to the line - video_console.m_Lines[ video_console.m_nCurLine ][ video_console.m_cCurLineLength ] = wch; - - float fTextWidth, fTextHeight; - - xdk360_video_font_get_text_width(&m_Font, video_console.m_Lines[ video_console.m_nCurLine ], &fTextWidth, - &fTextHeight, 0); - - if( fTextHeight > video_console.m_cxSafeArea ) - { - // The line is too long, we need to wrap the character to the next line - video_console.m_Lines[video_console.m_nCurLine][ video_console.m_cCurLineLength ] = L'\0'; - bIncrementLine = TRUE; - } - } - - // If we need to skip to the next line, do so - if( bIncrementLine ) - { - video_console.m_nCurLine = ( video_console.m_nCurLine + 1 ) - % video_console.m_cScreenHeightVirtual; - video_console.m_cCurLineLength = 0; - memset( video_console.m_Lines[video_console.m_nCurLine], - 0, ( video_console.m_cScreenWidth + 1 ) * sizeof( wchar_t ) ); - video_console.m_Lines[video_console.m_nCurLine ][0] = wch; - } - - video_console.m_cCurLineLength++; -} - -void xdk360_console_format(_In_z_ _Printf_format_string_ LPCSTR strFormat, ... ) -{ - video_console.m_nCurLine = 0; - video_console.m_cCurLineLength = 0; - - memset( video_console.m_Buffer, 0, - video_console.m_cScreenHeightVirtual * - ( video_console.m_cScreenWidth + 1 ) * sizeof( wchar_t ) ); - - va_list pArgList; - va_start( pArgList, strFormat ); - - // 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++ ) - { - wchar_t wch; - int ret = MultiByteToWideChar( - CP_ACP, // ANSI code page - 0, // No flags - &strMessage[i], // Character to convert - 1, // Convert one byte - &wch, // Target wide character buffer - 1 ); // One wide character - xdk360_console_add( wch ); - } - - _freea( strMessage ); - - va_end( pArgList ); -} - -#define CALCFONTFILEHEADERSIZE(x) ( sizeof(unsigned long) + (sizeof(float)* 4) + sizeof(unsigned short) + (sizeof(wchar_t)*(x)) ) -#define FONTFILEVERSION 5 - -typedef struct FontFileHeaderImage_t { - unsigned long m_dwFileVersion; // Version of the font file (Must match FONTFILEVERSION) - 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. -} 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; - -static PackedResource m_xprResource; - -static const char g_strFontShader[] = - "struct VS_IN\n" - "{\n" - "float2 Pos : POSITION;\n" - "float2 Tex : TEXCOORD0;\n" - "float4 ChannelSelector : TEXCOORD1;\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" - "uniform float4 Color : register(c1);\n" - "uniform float2 TexScale : register(c2);\n" - "sampler FontTexture : register(s0);\n" - "VS_OUT main_vertex( 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" - "float4 main_fragment( VS_OUT In ) : COLOR0\n" - "{\n" - "float4 FontTexel = tex2D( FontTexture, In.TexCoord0 );\n" - "if( dot( In.ChannelSelector, float4(1,1,1,1) ) )\n" - "{\n" - "float value = dot( FontTexel, In.ChannelSelector );\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" - "return Color * In.Diffuse;\n" - "}\n" - "else\n" - "{\n" - "return FontTexel * In.Diffuse;\n" - "}\n" - "}\n"; - -typedef struct Font_Locals_t { - D3DVertexDeclaration* m_pFontVertexDecl; // Shared vertex buffer - D3DVertexShader* m_pFontVertexShader; // Created vertex shader - D3DPixelShader* m_pFontPixelShader; // Created pixel shader -} Font_Locals_t; - -// All elements are defaulted to NULL -static Font_Locals_t s_FontLocals; // Global static instance - static HRESULT xdk360_video_font_create_shaders (xdk360_video_font_t * font) -{ - // - // 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 hr; if (!s_FontLocals.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 }, @@ -327,59 +372,51 @@ static HRESULT xdk360_video_font_create_shaders (xdk360_video_font_t * font) D3DDECL_END() }; - // Cache this global into a register xdk360_video_t *vid = (xdk360_video_t*)driver.video_data; D3DDevice *pd3dDevice = vid->d3d_render_device; hr = pd3dDevice->CreateVertexDeclaration( decl, &s_FontLocals.m_pFontVertexDecl ); - if (SUCCEEDED(hr)) + if (hr >= 0) { - // Step #2, create my vertex shader ID3DXBuffer* pShaderCode; hr = D3DXCompileShader( g_strFontShader, sizeof(g_strFontShader)-1 , NULL, NULL, "main_vertex", "vs.2.0", 0,&pShaderCode, NULL, NULL ); - if (SUCCEEDED(hr)) + + if (hr >= 0) { hr = pd3dDevice->CreateVertexShader( ( unsigned long * )pShaderCode->GetBufferPointer(), &s_FontLocals.m_pFontVertexShader ); - // Release the compiled shader pShaderCode->Release(); - if(SUCCEEDED(hr)) + if (hr >= 0) { - // Step #3, create my pixel shader hr = D3DXCompileShader( g_strFontShader, sizeof(g_strFontShader)-1 , NULL, NULL, "main_fragment", "ps.2.0", 0,&pShaderCode, NULL, NULL ); - if ( SUCCEEDED(hr)) + + if (hr >= 0) { hr = pd3dDevice->CreatePixelShader( ( DWORD* )pShaderCode->GetBufferPointer(), &s_FontLocals.m_pFontPixelShader ); - // Release the compiled shader pShaderCode->Release(); - if (SUCCEEDED(hr)) + if (hr >= 0) { - hr = S_OK; - break; // Skip the teardown code + hr = 0; + break; } } - - // If the code got to here, a fatal error has occured - // and a clean shutdown needs to be performed. D3DResource_Release((D3DResource *)s_FontLocals.m_pFontVertexShader); } - // Ensure the pointer is NULL s_FontLocals.m_pFontVertexShader = NULL; } D3DResource_Release((D3DResource *)s_FontLocals.m_pFontVertexDecl); - } - // Ensure this pointer is NULL + } s_FontLocals.m_pFontVertexDecl = NULL; - }while(0); // Exit point for the break command. + }while(0); return hr; } else @@ -387,18 +424,12 @@ static HRESULT xdk360_video_font_create_shaders (xdk360_video_font_t * font) D3DResource_AddRef((D3DResource *)s_FontLocals.m_pFontVertexDecl); D3DResource_AddRef((D3DResource *)s_FontLocals.m_pFontVertexShader); D3DResource_AddRef((D3DResource *)s_FontLocals.m_pFontPixelShader); - hr = S_OK; + hr = 0; } - return hr; // Return the error code if any + return hr; } -void xdk360_video_font_set_size(xdk360_video_font_t * font, float x, float y) -{ - font->m_fXScaleFactor = x; - font->m_fYScaleFactor = y; -} - -HRESULT xdk360_video_font_init(xdk360_video_font_t * font, const char * strFontFileName) +static HRESULT xdk360_video_font_init(xdk360_video_font_t * font, const char * strFontFileName) { font->m_pFontTexture = NULL; font->m_dwNumGlyphs = 0L; @@ -470,10 +501,70 @@ HRESULT xdk360_video_font_init(xdk360_video_font_t * font, const char * strFontF // Determine whether we should save/restore state font->m_bSaveState = TRUE; - return S_OK; + return 0; } -void xdk360_video_font_deinit(xdk360_video_font_t * font) +HRESULT xdk360_console_init( LPCSTR strFontFileName, unsigned long colBackColor, + unsigned long colTextColor) +{ + xdk360_video_t *vid = (xdk360_video_t*)driver.video_data; + D3DDevice *m_pd3dDevice = vid->d3d_render_device; + + video_console.first_message = true; + video_console.m_Buffer = NULL; + video_console.m_Lines = NULL; + video_console.m_nScrollOffset = 0; + + // Calculate the safe area + unsigned int uiSafeAreaPct = vid->video_mode.fIsHiDef ? SAFE_AREA_PCT_HDTV + : SAFE_AREA_PCT_4x3; + + video_console.m_cxSafeArea = ( vid->d3dpp.BackBufferWidth * uiSafeAreaPct ) / 100; + video_console.m_cySafeArea = ( vid->d3dpp.BackBufferHeight * uiSafeAreaPct ) / 100; + + video_console.m_cxSafeAreaOffset = ( vid->d3dpp.BackBufferWidth - video_console.m_cxSafeArea ) / 2; + video_console.m_cySafeAreaOffset = ( vid->d3dpp.BackBufferHeight - video_console.m_cySafeArea ) / 2; + + // Create the font + HRESULT hr = xdk360_video_font_init(&m_Font, strFontFileName ); + if (hr < 0) + { + RARCH_ERR( "Could not create font.\n" ); + return -1; + } + + // Save the colors + video_console.m_colBackColor = colBackColor; + video_console.m_colTextColor = colTextColor; + + // Calculate the number of lines on the screen + float fCharWidth, fCharHeight; + xdk360_video_font_get_text_width(&m_Font, L"i", &fCharWidth, &fCharHeight); + + video_console.m_cScreenHeight = (unsigned int)( video_console.m_cySafeArea / fCharHeight ); + video_console.m_cScreenWidth = (unsigned int)( video_console.m_cxSafeArea / fCharWidth ); + + video_console.m_cScreenHeightVirtual = video_console.m_cScreenHeight; + + 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 = new wchar_t *[ video_console.m_cScreenHeightVirtual ]; + + // 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; + + video_console.m_nCurLine = 0; + video_console.m_cCurLineLength = 0; + memset( video_console.m_Buffer, 0, video_console.m_cScreenHeightVirtual * ( video_console.m_cScreenWidth + 1 ) * sizeof( wchar_t ) ); + xdk360_console_draw(); + + return hr; +} + +static void xdk360_video_font_deinit(xdk360_video_font_t * font) { font->m_pFontTexture = NULL; font->m_dwNumGlyphs = 0L; @@ -497,79 +588,110 @@ void xdk360_video_font_deinit(xdk360_video_font_t * font) m_xprResource.Destroy(); } -void xdk360_video_font_set_cursor_position(xdk360_video_font_t *font, float fCursorX, float fCursorY ) +void xdk360_console_deinit() { - font->m_fCursorX = floorf( fCursorX ); - font->m_fCursorY = floorf( fCursorY ); + // Delete the memory we've allocated + if(video_console.m_Lines) + { + delete[] 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 + xdk360_video_font_deinit(&m_Font); } -void xdk360_video_font_get_text_width(xdk360_video_font_t * font, const wchar_t * strText, float * pWidth, float * pHeight, int bFirstLineOnly) +static void xdk360_console_add( wchar_t wch ) { - // Set default text extent in output parameters - int iWidth = 0; - float fHeight = 0.0f; + // If this is a newline, just increment lines and move on + if( wch == L'\n' ) + { + video_console.m_nCurLine = ( video_console.m_nCurLine + 1 ) + % video_console.m_cScreenHeightVirtual; + video_console.m_cCurLineLength = 0; + memset(video_console.m_Lines[video_console.m_nCurLine], 0, + ( video_console.m_cScreenWidth + 1 ) * sizeof( wchar_t ) ); + return; + } - if( strText ) - { - // Initialize counters that keep track of text extent - int ix = 0; - float fy = font->m_fFontHeight; // One character high to start - if( fy > fHeight ) - fHeight = fy; + int bIncrementLine = FALSE; // Whether to wrap to the next line - // Loop through each character and update text extent - unsigned long letter; - while( (letter = *strText) != 0 ) - { - ++strText; + if( video_console.m_cCurLineLength == video_console.m_cScreenWidth ) + bIncrementLine = TRUE; + else + { + // Try to append the character to the line + video_console.m_Lines[ video_console.m_nCurLine ][ video_console.m_cCurLineLength ] = wch; - // Handle newline character - if( letter == L'\n' ) - { - if( bFirstLineOnly ) - break; - ix = 0; - fy += font->m_fFontYAdvance; - // since the height has changed, test against the height extent - if( fy > fHeight ) - fHeight = fy; - } + float fTextWidth, fTextHeight; - // Handle carriage return characters by ignoring them. This helps when - // displaying text from a file. - if( letter == L'\r' ) - continue; + xdk360_video_font_get_text_width(&m_Font, video_console.m_Lines[ video_console.m_nCurLine ], &fTextWidth, + &fTextHeight); - // Translate unprintable characters - const GLYPH_ATTR* pGlyph; - - if( letter > font->m_cMaxGlyph ) - letter = 0; // Out of bounds? - else - letter = font->m_TranslatorTable[letter]; // Remap ASCII to glyph + if( fTextHeight > video_console.m_cxSafeArea ) + { + // The line is too long, we need to wrap the character to the next line + video_console.m_Lines[video_console.m_nCurLine][ video_console.m_cCurLineLength ] = L'\0'; + bIncrementLine = TRUE; + } + } - pGlyph = &font->m_Glyphs[letter]; // Get the requested glyph + // If we need to skip to the next line, do so + if( bIncrementLine ) + { + video_console.m_nCurLine = ( video_console.m_nCurLine + 1 ) + % video_console.m_cScreenHeightVirtual; + video_console.m_cCurLineLength = 0; + memset( video_console.m_Lines[video_console.m_nCurLine], + 0, ( video_console.m_cScreenWidth + 1 ) * sizeof( wchar_t ) ); + video_console.m_Lines[video_console.m_nCurLine ][0] = wch; + } - // Get text extent for this character's glyph - ix += pGlyph->wOffset; - ix += pGlyph->wAdvance; + video_console.m_cCurLineLength++; +} - // Since the x widened, test against the x extent +void xdk360_console_format(LPCSTR strFormat, ... ) +{ + video_console.m_nCurLine = 0; + video_console.m_cCurLineLength = 0; - if( ix > iWidth ) - iWidth = ix; - } - } + memset( video_console.m_Buffer, 0, + video_console.m_cScreenHeightVirtual * + ( video_console.m_cScreenWidth + 1 ) * sizeof( wchar_t ) ); - // Convert the width to a float here, load/hit/store. :( - float fWidth = static_cast(iWidth); // Delay the use if fWidth to reduce LHS pain - // Apply the scale factor to the result - fHeight *= font->m_fYScaleFactor; - // Store the final results - *pHeight = fHeight; + va_list pArgList; + va_start( pArgList, strFormat ); - fWidth *= font->m_fXScaleFactor; - *pWidth = fWidth; + // Count the required length of the string + unsigned long dwStrLen = _vscprintf( strFormat, pArgList ) + 1; + // +1 = null terminator + char * strMessage = ( char * )malloc( 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++ ) + { + wchar_t wch; + int ret = MultiByteToWideChar( + CP_ACP, // ANSI code page + 0, // No flags + &strMessage[i], // Character to convert + 1, // Convert one byte + &wch, // Target wide character buffer + 1 ); // One wide character + xdk360_console_add( wch ); + } + + free(strMessage); + + va_end( pArgList ); } void xdk360_video_font_begin (xdk360_video_font_t * font) @@ -678,186 +800,3 @@ void xdk360_video_font_end(xdk360_video_font_t * font) D3DDevice_SetSamplerState_AddressV_Inline(pD3dDevice, 0, font->m_dwSavedState[ SAVEDSTATE_D3DSAMP_ADDRESSV ] ); } } - -void xdk360_video_font_draw_text(xdk360_video_font_t * font, float fOriginX, float fOriginY, unsigned long dwColor, - 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] = ( ( 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 - xdk360_video_font_begin(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( FAILED( hr ) ) - 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; - - // 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(pVertex)[2] = (tu1<<16)|tv1; // Merged using big endian rules - reinterpret_cast(pVertex)[3] = dwChannelSelector; - pVertex[4] = X2; - pVertex[5] = Y2; - reinterpret_cast(pVertex)[6] = (tu2<<16)|tv1; // Merged using big endian rules - reinterpret_cast(pVertex)[7] = dwChannelSelector; - pVertex[8] = X3; - pVertex[9] = Y3; - reinterpret_cast(pVertex)[10] = (tu2<<16)|tv2; // Merged using big endian rules - reinterpret_cast(pVertex)[11] = dwChannelSelector; - pVertex[12] = X4; - pVertex[13] = Y4; - reinterpret_cast(pVertex)[14] = (tu1<<16)|tv2; // Merged using big endian rules - reinterpret_cast(pVertex)[15] = dwChannelSelector; - 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 ) - { - 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 - D3DDevice_EndVertices(pd3dDevice); - - // Undo window offsets - font->m_fCursorX -= Winx; - font->m_fCursorY -= Winy; - - // Call End() to complete the begin/end pair for drawing text - xdk360_video_font_end(font); -} diff --git a/360/fonts.h b/360/fonts.h index 033a464cf4..54ebecaaea 100644 --- a/360/fonts.h +++ b/360/fonts.h @@ -102,17 +102,10 @@ typedef struct HRESULT xdk360_console_init ( LPCSTR strFontFileName, D3DCOLOR colBackColor, D3DCOLOR colTextColor); void xdk360_console_deinit (void); -void xdk360_console_format (_In_z_ _Printf_format_string_ LPCSTR strFormat, ... ); +void xdk360_console_format (LPCSTR strFormat, ... ); void xdk360_console_draw (void); -HRESULT xdk360_video_font_init(xdk360_video_font_t * font, const char * strFontFileName); -void xdk360_video_font_get_text_width(xdk360_video_font_t * font, const wchar_t * strText, float * pWidth, float * pHeight, int bFirstLineOnly); -void xdk360_video_font_deinit(xdk360_video_font_t * font); -void xdk360_video_font_set_cursor_position(xdk360_video_font_t *font, float fCursorX, float fCursorY ); void xdk360_video_font_begin (xdk360_video_font_t * font); void xdk360_video_font_end (xdk360_video_font_t * font); -void xdk360_video_font_set_size(float x, float y); -void xdk360_video_font_draw_text(xdk360_video_font_t * font, float fOriginX, float fOriginY, unsigned long dwColor, -const wchar_t * strText, float fMaxPixelWidth ); #endif diff --git a/360/main.c b/360/main.c index c010ed7ad3..05b8c8fa47 100644 --- a/360/main.c +++ b/360/main.c @@ -29,7 +29,6 @@ #include "../conf/config_file_macros.h" #include "../file.h" #include "../general.h" -#include "shared.h" #define DEVICE_MEMORY_UNIT0 1 #define DEVICE_MEMORY_UNIT1 2 @@ -49,8 +48,8 @@ typedef struct _STRING { char * Buffer; } STRING; -char DEFAULT_SHADER_FILE[MAX_PATH_LENGTH]; -char SYS_CONFIG_FILE[MAX_PATH_LENGTH]; +char DEFAULT_SHADER_FILE[PATH_MAX]; +char SYS_CONFIG_FILE[PATH_MAX]; extern "C" int __stdcall ObCreateSymbolicLink( STRING*, STRING*); @@ -134,6 +133,8 @@ static void set_default_settings (void) strlcpy(g_settings.video.cg_shader_path, DEFAULT_SHADER_FILE, sizeof(g_settings.video.cg_shader_path)); g_settings.video.fbo_scale_x = 2.0f; g_settings.video.fbo_scale_y = 2.0f; + g_settings.video.render_to_texture = true; + strlcpy(g_settings.video.second_pass_shader, DEFAULT_SHADER_FILE, sizeof(g_settings.video.second_pass_shader)); g_settings.video.second_pass_smooth = true; g_settings.video.smooth = true; g_settings.video.vsync = true; @@ -176,6 +177,7 @@ static void set_default_settings (void) g_console.viewports.custom_vp.x = 0; g_console.viewports.custom_vp.y = 0; g_console.color_format = 0; + g_console.info_msg_enable = true; //g_extern g_extern.state_slot = 0; @@ -183,149 +185,6 @@ static void set_default_settings (void) g_extern.verbose = true; } -static void init_settings (bool load_libretro_path) -{ - char fname_tmp[MAX_PATH_LENGTH]; - - if(!path_file_exists(SYS_CONFIG_FILE)) - { - FILE * f; - RARCH_ERR("Config file \"%s\" desn't exist. Creating...\n", "game:\\retroarch.cfg"); - f = fopen(SYS_CONFIG_FILE, "w"); - fclose(f); - } - - config_file_t * conf = config_file_new(SYS_CONFIG_FILE); - - if(load_libretro_path) - { - CONFIG_GET_STRING(libretro, "libretro_path"); - - if(!strcmp(g_settings.libretro, "")) - { - //We need to set libretro to the first entry in the cores - //directory so that it will be saved to the config file - char ** dir_list = dir_list_new("game:\\", ".xex"); - - if (!dir_list) - { - RARCH_ERR("Couldn't read directory.\n"); - return; - } - - const char * first_xex = dir_list[0]; - - if(first_xex) - { - fill_pathname_base(fname_tmp, first_xex, sizeof(fname_tmp)); - - if(strcmp(fname_tmp, "RetroArch-Salamander.xex") == 0) - { - RARCH_WARN("First entry is RetroArch Salamander itself, increment entry by one and check if it exists.\n"); - first_xex = dir_list[1]; - fill_pathname_base(fname_tmp, first_xex, sizeof(fname_tmp)); - - if(!first_xex) - { - //This is very unlikely to happen - RARCH_WARN("There is no second entry - no choice but to set it to RetroArch Salamander\n"); - first_xex = dir_list[0]; - fill_pathname_base(fname_tmp, first_xex, sizeof(fname_tmp)); - } - } - RARCH_LOG("Set first .xex entry in dir: [%s] to libretro path.\n", fname_tmp); - snprintf(g_settings.libretro, sizeof(g_settings.libretro), "game:\\%s", fname_tmp); - } - else - { - RARCH_ERR("Failed to set first .xex entry to libretro path.\n"); - } - - dir_list_free(dir_list); - } - } - - // g_settings - CONFIG_GET_STRING(cheat_database, "cheat_database"); - CONFIG_GET_BOOL(rewind_enable, "rewind_enable"); - CONFIG_GET_STRING(video.cg_shader_path, "video_cg_shader"); - CONFIG_GET_STRING(video.second_pass_shader, "video_second_pass_shader"); - CONFIG_GET_FLOAT(video.fbo_scale_x, "video_fbo_scale_x"); - CONFIG_GET_FLOAT(video.fbo_scale_y, "video_fbo_scale_y"); - CONFIG_GET_BOOL(video.render_to_texture, "video_render_to_texture"); - CONFIG_GET_BOOL(video.second_pass_smooth, "video_second_pass_smooth"); - CONFIG_GET_BOOL(video.smooth, "video_smooth"); - CONFIG_GET_BOOL(video.vsync, "video_vsync"); - CONFIG_GET_FLOAT(video.aspect_ratio, "video_aspect_ratio"); - - // g_console - CONFIG_GET_BOOL_CONSOLE(fbo_enabled, "fbo_enabled"); - CONFIG_GET_BOOL_CONSOLE(throttle_enable, "throttle_enable"); - CONFIG_GET_BOOL_CONSOLE(gamma_correction_enable, "gamma_correction_enable"); - CONFIG_GET_STRING_CONSOLE(default_rom_startup_dir, "default_rom_startup_dir"); - CONFIG_GET_INT_CONSOLE(aspect_ratio_index, "aspect_ratio_index"); - CONFIG_GET_INT_CONSOLE(viewports.custom_vp.x, "custom_viewport_x"); - CONFIG_GET_INT_CONSOLE(viewports.custom_vp.y, "custom_viewport_y"); - CONFIG_GET_INT_CONSOLE(viewports.custom_vp.width, "custom_viewport_width"); - CONFIG_GET_INT_CONSOLE(viewports.custom_vp.height, "custom_viewport_height"); - CONFIG_GET_INT_CONSOLE(screen_orientation, "screen_orientation"); - CONFIG_GET_INT_CONSOLE(color_format, "color_format"); - - // g_extern - CONFIG_GET_INT_EXTERN(state_slot, "state_slot"); - CONFIG_GET_INT_EXTERN(audio_data.mute, "audio_mute"); -} - -static void save_settings (void) -{ - if(!path_file_exists(SYS_CONFIG_FILE)) - { - FILE * f; - f = fopen(SYS_CONFIG_FILE, "w"); - fclose(f); - } - - config_file_t * conf = config_file_new(SYS_CONFIG_FILE); - - if(conf == NULL) - conf = config_file_new(NULL); - - // g_settings - config_set_string(conf, "libretro_path", g_settings.libretro); - config_set_bool(conf, "rewind_enable", g_settings.rewind_enable); - config_set_string(conf, "video_cg_shader", g_settings.video.cg_shader_path); - config_set_string(conf, "video_second_pass_shader", g_settings.video.second_pass_shader); - config_set_float(conf, "video_aspect_ratio", g_settings.video.aspect_ratio); - config_set_float(conf, "video_fbo_scale_x", g_settings.video.fbo_scale_x); - config_set_float(conf, "video_fbo_scale_y", g_settings.video.fbo_scale_y); - config_set_bool(conf, "video_render_to_texture", g_settings.video.render_to_texture); - config_set_bool(conf, "video_second_pass_smooth", g_settings.video.second_pass_smooth); - config_set_bool(conf, "video_smooth", g_settings.video.smooth); - config_set_bool(conf, "video_vsync", g_settings.video.vsync); - - // g_console - config_set_bool(conf, "fbo_enabled", g_console.fbo_enabled); - config_set_string(conf, "default_rom_startup_dir", g_console.default_rom_startup_dir); - config_set_bool(conf, "gamma_correction_enable", g_console.gamma_correction_enable); - config_set_bool(conf, "throttle_enable", g_console.throttle_enable); - config_set_int(conf, "aspect_ratio_index", g_console.aspect_ratio_index); - config_set_int(conf, "custom_viewport_width", g_console.viewports.custom_vp.width); - config_set_int(conf, "custom_viewport_height", g_console.viewports.custom_vp.height); - config_set_int(conf, "custom_viewport_x", g_console.viewports.custom_vp.x); - config_set_int(conf, "custom_viewport_y", g_console.viewports.custom_vp.y); - config_set_int(conf, "screen_orientation", g_console.screen_orientation); - config_set_int(conf, "color_format", g_console.color_format); - - // g_extern - config_set_int(conf, "state_slot", g_extern.state_slot); - config_set_int(conf, "audio_mute", g_extern.audio_data.mute); - - if (!config_file_write(conf, SYS_CONFIG_FILE)) - RARCH_ERR("Failed to write config file to \"%s\". Check permissions.\n", SYS_CONFIG_FILE); - - free(conf); -} - static void get_environment_settings (void) { DWORD ret; @@ -407,15 +266,24 @@ int main(int argc, char *argv[]) rarch_main_clear_state(); config_set_defaults(); - rarch_assert(g_extern.msg_queue = msg_queue_new(8)); - char full_path[1024]; snprintf(full_path, sizeof(full_path), "game:\\CORE.xex"); - bool load_libretro_path = rarch_manage_libretro_core(full_path, "game:\\", ".xex"); + g_extern.verbose = true; + + const char *libretro_core_installed = rarch_manage_libretro_install(full_path, "game:\\", ".xex"); + + g_extern.verbose = false; + + bool find_libretro_file = false; + + if(libretro_core_installed != NULL) + strlcpy(g_settings.libretro, libretro_core_installed, sizeof(g_settings.libretro)); + else + find_libretro_file = true; set_default_settings(); - init_settings(load_libretro_path); + rarch_config_load(SYS_CONFIG_FILE, "game:\\", ".xex", find_libretro_file); init_libretro_sym(); video_xdk360.start(); @@ -450,7 +318,7 @@ begin_loop: begin_shutdown: if(path_file_exists(SYS_CONFIG_FILE)) - save_settings(); + rarch_config_save(SYS_CONFIG_FILE); menu_deinit(); video_xdk360.stop(); diff --git a/360/media/hd/rarch_settings.xui b/360/media/hd/rarch_settings.xui index 351e530561..df33f2460f 100644 --- a/360/media/hd/rarch_settings.xui +++ b/360/media/hd/rarch_settings.xui @@ -31,6 +31,8 @@ 383.040009 44.880005,64.959991,0.000000 Rewind: +Info messages: +Menus: Gamma Correction: Color Format: Shader #1: @@ -197,6 +199,18 @@ Custom Scaling Factor: 0.000000,10.000000,0.000000 + + +control_ListItem +226.000000 +45.000000 +7.000000,22.000000,0.000000 +5 +false +XuiButton +0.000000,10.000000,0.000000 + + diff --git a/360/media/sd/rarch_settings.xui b/360/media/sd/rarch_settings.xui index e04bd092bf..3b63a8a502 100644 --- a/360/media/sd/rarch_settings.xui +++ b/360/media/sd/rarch_settings.xui @@ -31,6 +31,8 @@ 232.720001 44.880005,64.959991,0.000000 Rewind: +Info messages: +Menus: Color Format: Gamma Correction: Shader #1: @@ -173,6 +175,18 @@ Cutom Scaling Factor: 0.000000,10.000000,0.000000 + + +control_ListItem +226.000000 +45.000000 +7.000000,22.000000,0.000000 +5 +false +XuiButton +0.000000,10.000000,0.000000 + + diff --git a/360/menu.cpp b/360/menu.cpp index 563bdd4f94..444e6bbf64 100644 --- a/360/menu.cpp +++ b/360/menu.cpp @@ -23,30 +23,15 @@ #include "xdk360_video.h" #include "menu.h" #include "../message.h" -#include "shared.h" #include "../general.h" -CRetroArch app; +CRetroArch app; HXUIOBJ hCur; filebrowser_t browser; filebrowser_t tmp_browser; -bool hdmenus_allowed; uint32_t set_shader = 0; - -static void return_to_game (void) -{ - g_console.frame_advance_enable = false; - g_console.menu_enable = false; - g_console.mode_switch = MODE_EMULATION; -} - -static void return_to_dashboard (void) -{ - g_console.menu_enable = false; - g_console.mode_switch = MODE_EXIT; - g_console.initialize_rarch_enable = false; -} +wchar_t strw_buffer[PATH_MAX]; /* Register custom classes */ HRESULT CRetroArch::RegisterXuiClasses (void) @@ -59,7 +44,7 @@ HRESULT CRetroArch::RegisterXuiClasses (void) CRetroArchControls::Register(); CRetroArchSettings::Register(); - return S_OK; + return 0; } /* Unregister custom classes */ @@ -73,7 +58,7 @@ HRESULT CRetroArch::UnregisterXuiClasses (void) CRetroArchControls::Register(); CRetroArchSettings::Unregister(); - return S_OK; + return 0; } static void filebrowser_fetch_directory_entries(const char *path, filebrowser_t * browser, CXuiList * romlist, @@ -81,17 +66,15 @@ static void filebrowser_fetch_directory_entries(const char *path, filebrowser_t { filebrowser_push_directory(browser, path, true); - wchar_t * rompath_name = rarch_convert_char_to_wchar(path); - rompath_title->SetText(rompath_name); - free(rompath_name); + rarch_convert_char_to_wchar(strw_buffer, path, sizeof(strw_buffer)); + rompath_title->SetText(strw_buffer); romlist->DeleteItems(0, romlist->GetItemCount()); romlist->InsertItems(0, browser->file_count); for(unsigned i = 0; i < browser->file_count; i++) { - wchar_t * entry_name = rarch_convert_char_to_wchar(browser->cur[i].d_name); - romlist->SetText(i, entry_name); - free(entry_name); + rarch_convert_char_to_wchar(strw_buffer, browser->cur[i].d_name, sizeof(strw_buffer)); + romlist->SetText(i, strw_buffer); } } @@ -105,7 +88,7 @@ HRESULT CRetroArchFileBrowser::OnInit(XUIMessageInit * pInitData, BOOL& bHandled filebrowser_fetch_directory_entries(g_console.default_rom_startup_dir, &browser, &m_romlist, &m_rompathtitle); - return S_OK; + return 0; } HRESULT CRetroArchCoreBrowser::OnInit(XUIMessageInit * pInitData, BOOL& bHandled) @@ -117,7 +100,7 @@ HRESULT CRetroArchCoreBrowser::OnInit(XUIMessageInit * pInitData, BOOL& bHandled filebrowser_new(&tmp_browser, "game:", "xex|XEX"); filebrowser_fetch_directory_entries("game:", &tmp_browser, &m_romlist, &m_rompathtitle); - return S_OK; + return 0; } HRESULT CRetroArchShaderBrowser::OnInit(XUIMessageInit * pInitData, BOOL& bHandled) @@ -129,7 +112,7 @@ HRESULT CRetroArchShaderBrowser::OnInit(XUIMessageInit * pInitData, BOOL& bHandl filebrowser_new(&tmp_browser, "game:\\media\\shaders", "cg|CG"); filebrowser_fetch_directory_entries("game:\\media\\shaders", &tmp_browser, &m_shaderlist, &m_shaderpathtitle); - return S_OK; + return 0; } HRESULT CRetroArchControls::OnInit(XUIMessageInit * pInitData, BOOL& bHandled) @@ -147,11 +130,12 @@ HRESULT CRetroArchControls::OnInit(XUIMessageInit * pInitData, BOOL& bHandled) for(i = 0; i < RARCH_FIRST_META_KEY; i++) { - snprintf(buttons[i], sizeof(buttons[i]), "%s #%d: %s", rarch_default_libretro_keybind_name_lut[i], controlno, rarch_input_find_platform_key_label(g_settings.input.binds[controlno][i].joykey)); - m_controlslist.SetText(i, rarch_convert_char_to_wchar(buttons[i])); + snprintf(buttons[i], sizeof(buttons[i]), "%s #%d: %s", rarch_default_libretro_keybind_name_lut[i], controlno, rarch_input_find_platform_key_label(g_settings.input.binds[controlno][i].joykey)); + rarch_convert_char_to_wchar(strw_buffer, buttons[i], sizeof(strw_buffer)); + m_controlslist.SetText(i, strw_buffer); } - return S_OK; + return 0; } HRESULT CRetroArchControls::OnControlNavigate(XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled) @@ -165,34 +149,37 @@ HRESULT CRetroArchControls::OnControlNavigate(XUIMessageControlNavigate *pContro for(i = 0; i < RARCH_FIRST_META_KEY; i++) { - snprintf(buttons[i], sizeof(buttons[i]), "%s #%d: %s", rarch_default_libretro_keybind_name_lut[i], controlno, rarch_input_find_platform_key_label(g_settings.input.binds[controlno][i].joykey)); - m_controlslist.SetText(i, rarch_convert_char_to_wchar(buttons[i])); + snprintf(buttons[i], sizeof(buttons[i]), "%s #%d: %s", rarch_default_libretro_keybind_name_lut[i], controlno, rarch_input_find_platform_key_label(g_settings.input.binds[controlno][i].joykey)); + rarch_convert_char_to_wchar(strw_buffer, buttons[i], sizeof(strw_buffer)); + m_controlslist.SetText(i, strw_buffer); } - switch(pControlNavigateData->nControlNavigate) - { - case XUI_CONTROL_NAVIGATE_LEFT: - if(current_index > 0 && current_index != SETTING_CONTROLS_DEFAULT_ALL) - { - rarch_input_set_keybind(controlno, KEYBIND_DECREMENT, current_index); - snprintf(button, sizeof(button), "%s #%d: %s", rarch_default_libretro_keybind_name_lut[current_index], controlno, rarch_input_find_platform_key_label(g_settings.input.binds[controlno][current_index].joykey)); - m_controlslist.SetText(current_index, rarch_convert_char_to_wchar(button)); - } - break; - case XUI_CONTROL_NAVIGATE_RIGHT: - if(current_index < RARCH_FIRST_META_KEY && current_index != SETTING_CONTROLS_DEFAULT_ALL) - { - rarch_input_set_keybind(controlno, KEYBIND_INCREMENT, current_index); - snprintf(button, sizeof(button), "%s #%d: %s", rarch_default_libretro_keybind_name_lut[current_index], controlno, rarch_input_find_platform_key_label(g_settings.input.binds[controlno][current_index].joykey)); - m_controlslist.SetText(current_index, rarch_convert_char_to_wchar(button)); - } - break; - case XUI_CONTROL_NAVIGATE_UP: - case XUI_CONTROL_NAVIGATE_DOWN: - break; - } + switch(pControlNavigateData->nControlNavigate) + { + case XUI_CONTROL_NAVIGATE_LEFT: + if(current_index > 0 && current_index != SETTING_CONTROLS_DEFAULT_ALL) + { + rarch_input_set_keybind(controlno, KEYBIND_DECREMENT, current_index); + snprintf(button, sizeof(button), "%s #%d: %s", rarch_default_libretro_keybind_name_lut[current_index], controlno, rarch_input_find_platform_key_label(g_settings.input.binds[controlno][current_index].joykey)); + rarch_convert_char_to_wchar(strw_buffer, button, sizeof(strw_buffer)); + m_controlslist.SetText(current_index, strw_buffer); + } + break; + case XUI_CONTROL_NAVIGATE_RIGHT: + if(current_index < RARCH_FIRST_META_KEY && current_index != SETTING_CONTROLS_DEFAULT_ALL) + { + rarch_input_set_keybind(controlno, KEYBIND_INCREMENT, current_index); + snprintf(button, sizeof(button), "%s #%d: %s", rarch_default_libretro_keybind_name_lut[current_index], controlno, rarch_input_find_platform_key_label(g_settings.input.binds[controlno][current_index].joykey)); + rarch_convert_char_to_wchar(strw_buffer, button, sizeof(strw_buffer)); + m_controlslist.SetText(current_index, strw_buffer); + } + break; + case XUI_CONTROL_NAVIGATE_UP: + case XUI_CONTROL_NAVIGATE_DOWN: + break; + } - return S_OK; + return 0; } HRESULT CRetroArchControls::OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled ) @@ -212,127 +199,217 @@ HRESULT CRetroArchControls::OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled for(i = 0; i < RARCH_FIRST_META_KEY; i++) { - snprintf(buttons[i], sizeof(buttons[i]), "%s #%d: %s", rarch_default_libretro_keybind_name_lut[i], controlno, rarch_input_find_platform_key_label(g_settings.input.binds[controlno][i].joykey)); - m_controlslist.SetText(i, rarch_convert_char_to_wchar(buttons[i])); + snprintf(buttons[i], sizeof(buttons[i]), "%s #%d: %s", rarch_default_libretro_keybind_name_lut[i], controlno, rarch_input_find_platform_key_label(g_settings.input.binds[controlno][i].joykey)); + rarch_convert_char_to_wchar(strw_buffer, buttons[i], sizeof(strw_buffer)); + m_controlslist.SetText(i, strw_buffer); } break; default: rarch_input_set_keybind(controlno, KEYBIND_DEFAULT, current_index); - snprintf(buttons[current_index], sizeof(buttons[current_index]), "%s #%d: %s", rarch_default_libretro_keybind_name_lut[current_index], controlno, rarch_input_find_platform_key_label(g_settings.input.binds[controlno][current_index].joykey)); - m_controlslist.SetText(current_index, rarch_convert_char_to_wchar(buttons[current_index])); + snprintf(buttons[current_index], sizeof(buttons[current_index]), "%s #%d: %s", rarch_default_libretro_keybind_name_lut[current_index], controlno, rarch_input_find_platform_key_label(g_settings.input.binds[controlno][current_index].joykey)); + rarch_convert_char_to_wchar(strw_buffer, buttons[current_index], sizeof(strw_buffer)); + m_controlslist.SetText(current_index, strw_buffer); break; } } bHandled = TRUE; - return S_OK; + return 0; } HRESULT CRetroArchSettings::OnInit(XUIMessageInit * pInitData, BOOL& bHandled) { - char shader1str[128], shader2str[128], scalefactor[128]; GetChildById(L"XuiSettingsList", &m_settingslist); GetChildById(L"XuiBackButton", &m_back); - snprintf(shader1str, sizeof(shader1str), "Shader #1: %s", g_settings.video.cg_shader_path); - snprintf(shader2str, sizeof(shader2str), "Shader #2: %s", g_settings.video.second_pass_shader); - snprintf(scalefactor, sizeof(scalefactor), "Scale Factor: %f (X) / %f (Y)", g_settings.video.fbo_scale_x, g_settings.video.fbo_scale_y); - m_settingslist.SetText(SETTING_EMU_REWIND_ENABLED, g_settings.rewind_enable ? L"Rewind: ON" : L"Rewind: OFF"); + m_settingslist.SetText(SETTING_EMU_SHOW_INFO_MSG, g_console.info_msg_enable ? L"Info messages: ON" : L"Info messages: OFF"); + m_settingslist.SetText(SETTING_EMU_MENUS, g_console.menus_hd_enable ? L"Menus: HD" : L"Menus: SD"); m_settingslist.SetText(SETTING_GAMMA_CORRECTION_ENABLED, g_console.gamma_correction_enable ? L"Gamma correction: ON" : L"Gamma correction: OFF"); m_settingslist.SetText(SETTING_HW_TEXTURE_FILTER, g_settings.video.smooth ? L"Hardware filtering shader #1: Linear interpolation" : L"Hardware filtering shader #1: Point filtering"); m_settingslist.SetText(SETTING_HW_TEXTURE_FILTER_2, g_settings.video.second_pass_smooth ? L"Hardware filtering shader #2: Linear interpolation" : L"Hardware filtering shader #2: Point filtering"); m_settingslist.SetText(SETTING_SCALE_ENABLED, g_console.fbo_enabled ? L"Custom Scaling/Dual Shaders: ON" : L"Custom Scaling/Dual Shaders: OFF"); - m_settingslist.SetText(SETTING_SHADER, rarch_convert_char_to_wchar(shader1str)); + rarch_settings_create_menu_item_label(strw_buffer, S_LBL_SHADER, sizeof(strw_buffer)); + m_settingslist.SetText(SETTING_SHADER, strw_buffer); m_settingslist.SetText(SETTING_COLOR_FORMAT, g_console.color_format ? L"Color format: 32bit ARGB" : L"Color format: 16bit RGBA"); - m_settingslist.SetText(SETTING_SHADER_2, rarch_convert_char_to_wchar(shader2str)); - m_settingslist.SetText(SETTING_SCALE_FACTOR, rarch_convert_char_to_wchar(scalefactor)); + rarch_settings_create_menu_item_label(strw_buffer, S_LBL_SHADER_2, sizeof(strw_buffer)); + m_settingslist.SetText(SETTING_SHADER_2, strw_buffer); + rarch_settings_create_menu_item_label(strw_buffer, S_LBL_SCALE_FACTOR, sizeof(strw_buffer)); + m_settingslist.SetText(SETTING_SCALE_FACTOR, strw_buffer); - return S_OK; + return 0; } HRESULT CRetroArchSettings::OnControlNavigate(XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled) { - char scalefactor[128]; int current_index; xdk360_video_t *vid = (xdk360_video_t*)driver.video_data; current_index = m_settingslist.GetCurSel(); - switch(pControlNavigateData->nControlNavigate) + switch(pControlNavigateData->nControlNavigate) + { + case XUI_CONTROL_NAVIGATE_LEFT: + switch(current_index) + { + case SETTING_SCALE_FACTOR: + if(vid->fbo_enabled) + { + if((g_settings.video.fbo_scale_x > MIN_SCALING_FACTOR)) + { + rarch_settings_change(S_SCALE_FACTOR_DECREMENT); + //xdk360_gfx_init_fbo(vid); + rarch_settings_create_menu_item_label(strw_buffer, S_LBL_SCALE_FACTOR, sizeof(strw_buffer)); + m_settingslist.SetText(SETTING_SCALE_FACTOR, strw_buffer); + } + } + default: + break; + } + break; + case XUI_CONTROL_NAVIGATE_RIGHT: + switch(current_index) + { + case SETTING_SCALE_FACTOR: + if(vid->fbo_enabled) + { + if((g_settings.video.fbo_scale_x < MAX_SCALING_FACTOR)) + { + rarch_settings_change(S_SCALE_FACTOR_INCREMENT); + //xdk360_gfx_init_fbo(vid); + rarch_settings_create_menu_item_label(strw_buffer, S_LBL_SCALE_FACTOR, sizeof(strw_buffer)); + m_settingslist.SetText(SETTING_SCALE_FACTOR, strw_buffer); + } + } + default: + break; + } + break; + case XUI_CONTROL_NAVIGATE_UP: + case XUI_CONTROL_NAVIGATE_DOWN: + break; + } + + bHandled = TRUE; + + switch(pControlNavigateData->nControlNavigate) { case XUI_CONTROL_NAVIGATE_LEFT: - switch(current_index) - { - case SETTING_SCALE_FACTOR: - if(vid->fbo_enabled) - { - if((g_settings.video.fbo_scale_x > MIN_SCALING_FACTOR)) - { - g_settings.video.fbo_scale_x -= 1.0f; - g_settings.video.fbo_scale_y -= 1.0f; - //xdk360_gfx_init_fbo(vid); - snprintf(scalefactor, sizeof(scalefactor), "Scale Factor: %f (X) / %f (Y)", g_settings.video.fbo_scale_x, g_settings.video.fbo_scale_y); - m_settingslist.SetText(SETTING_SCALE_FACTOR, rarch_convert_char_to_wchar(scalefactor)); - } - } - default: - break; - } + case XUI_CONTROL_NAVIGATE_RIGHT: + case XUI_CONTROL_NAVIGATE_UP: + case XUI_CONTROL_NAVIGATE_DOWN: + pControlNavigateData->hObjDest = pControlNavigateData->hObjSource; break; - case XUI_CONTROL_NAVIGATE_RIGHT: - switch(current_index) - { - case SETTING_SCALE_FACTOR: - if(vid->fbo_enabled) - { - if((g_settings.video.fbo_scale_x < MAX_SCALING_FACTOR)) - { - g_settings.video.fbo_scale_x += 1.0f; - g_settings.video.fbo_scale_y += 1.0f; - //xdk360_gfx_init_fbo(vid); - snprintf(scalefactor, sizeof(scalefactor), "Scale Factor: %f (X) / %f (Y)", g_settings.video.fbo_scale_x, g_settings.video.fbo_scale_y); - m_settingslist.SetText(SETTING_SCALE_FACTOR, rarch_convert_char_to_wchar(scalefactor)); - } - } - default: - break; - } - break; - case XUI_CONTROL_NAVIGATE_UP: - case XUI_CONTROL_NAVIGATE_DOWN: - break; - } + } - return S_OK; + return 0; } HRESULT CRetroArchQuickMenu::OnInit(XUIMessageInit * pInitData, BOOL& bHandled) { GetChildById(L"XuiQuickMenuList", &m_quickmenulist); GetChildById(L"XuiBackButton", &m_back); - switch(g_console.screen_orientation) - { - case ORIENTATION_NORMAL: - m_quickmenulist.SetText(MENU_ITEM_ORIENTATION, L"Orientation: Normal"); - break; - case ORIENTATION_VERTICAL: - m_quickmenulist.SetText(MENU_ITEM_ORIENTATION, L"Orientation: Vertical"); - break; - case ORIENTATION_FLIPPED: - m_quickmenulist.SetText(MENU_ITEM_ORIENTATION, L"Orientation: Flipped"); - break; - case ORIENTATION_FLIPPED_ROTATED: - m_quickmenulist.SetText(MENU_ITEM_ORIENTATION, L"Orientation: Flipped Rotated"); - break; - } - char aspectratio_label[32]; - snprintf(aspectratio_label, sizeof(aspectratio_label), "Aspect Ratio: %s", aspectratio_lut[g_console.aspect_ratio_index].name); - wchar_t * aspectratio_label_w = rarch_convert_char_to_wchar(aspectratio_label); - m_quickmenulist.SetText(MENU_ITEM_KEEP_ASPECT_RATIO, aspectratio_label_w); - free(aspectratio_label_w); - return S_OK; + rarch_settings_create_menu_item_label(strw_buffer, S_LBL_ROTATION, sizeof(strw_buffer)); + m_quickmenulist.SetText(MENU_ITEM_ORIENTATION, strw_buffer); + + rarch_settings_create_menu_item_label(strw_buffer, S_LBL_ASPECT_RATIO, sizeof(strw_buffer)); + m_quickmenulist.SetText(MENU_ITEM_KEEP_ASPECT_RATIO, strw_buffer); + + rarch_settings_create_menu_item_label(strw_buffer, S_LBL_LOAD_STATE_SLOT, sizeof(strw_buffer)); + m_quickmenulist.SetText(MENU_ITEM_LOAD_STATE, strw_buffer); + + rarch_settings_create_menu_item_label(strw_buffer, S_LBL_SAVE_STATE_SLOT, sizeof(strw_buffer)); + m_quickmenulist.SetText(MENU_ITEM_SAVE_STATE, strw_buffer); + + return 0; +} + +HRESULT CRetroArchQuickMenu::OnControlNavigate(XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled) +{ + bool aspectratio_changed = false; + int current_index; + xdk360_video_t *d3d9 = (xdk360_video_t*)driver.video_data; + + current_index = m_quickmenulist.GetCurSel(); + + switch(pControlNavigateData->nControlNavigate) + { + case XUI_CONTROL_NAVIGATE_LEFT: + switch(current_index) + { + case MENU_ITEM_LOAD_STATE: + case MENU_ITEM_SAVE_STATE: + rarch_state_slot_decrease(); + rarch_settings_create_menu_item_label(strw_buffer, S_LBL_LOAD_STATE_SLOT, sizeof(strw_buffer)); + m_quickmenulist.SetText(MENU_ITEM_LOAD_STATE, strw_buffer); + rarch_settings_create_menu_item_label(strw_buffer, S_LBL_SAVE_STATE_SLOT, sizeof(strw_buffer)); + m_quickmenulist.SetText(MENU_ITEM_SAVE_STATE, strw_buffer); + break; + case MENU_ITEM_KEEP_ASPECT_RATIO: + rarch_settings_change(S_ASPECT_RATIO_DECREMENT); + aspectratio_changed = true; + break; + case MENU_ITEM_ORIENTATION: + rarch_settings_change(S_ROTATION_DECREMENT); + rarch_settings_create_menu_item_label(strw_buffer, S_LBL_ROTATION, sizeof(strw_buffer)); + m_quickmenulist.SetText(MENU_ITEM_ORIENTATION, strw_buffer); + video_xdk360.set_rotation(driver.video_data, g_console.screen_orientation); + break; + default: + break; + } + break; + case XUI_CONTROL_NAVIGATE_RIGHT: + switch(current_index) + { + case MENU_ITEM_LOAD_STATE: + case MENU_ITEM_SAVE_STATE: + rarch_state_slot_increase(); + rarch_settings_create_menu_item_label(strw_buffer, S_LBL_LOAD_STATE_SLOT, sizeof(strw_buffer)); + m_quickmenulist.SetText(MENU_ITEM_LOAD_STATE, strw_buffer); + rarch_settings_create_menu_item_label(strw_buffer, S_LBL_SAVE_STATE_SLOT, sizeof(strw_buffer)); + m_quickmenulist.SetText(MENU_ITEM_SAVE_STATE, strw_buffer); + break; + case MENU_ITEM_KEEP_ASPECT_RATIO: + rarch_settings_change(S_ASPECT_RATIO_INCREMENT); + aspectratio_changed = true; + break; + case MENU_ITEM_ORIENTATION: + rarch_settings_change(S_ROTATION_INCREMENT); + rarch_settings_create_menu_item_label(strw_buffer, S_LBL_ROTATION, sizeof(strw_buffer)); + m_quickmenulist.SetText(MENU_ITEM_ORIENTATION, strw_buffer); + video_xdk360.set_rotation(driver.video_data, g_console.screen_orientation); + break; + default: + break; + } + break; + case XUI_CONTROL_NAVIGATE_UP: + case XUI_CONTROL_NAVIGATE_DOWN: + break; + } + + if(aspectratio_changed) + { + gfx_ctx_set_aspect_ratio(d3d9, g_console.aspect_ratio_index); + rarch_settings_create_menu_item_label(strw_buffer, S_LBL_ASPECT_RATIO, sizeof(strw_buffer)); + m_quickmenulist.SetText(MENU_ITEM_KEEP_ASPECT_RATIO, strw_buffer); + } + + bHandled = TRUE; + + switch(pControlNavigateData->nControlNavigate) + { + case XUI_CONTROL_NAVIGATE_LEFT: + case XUI_CONTROL_NAVIGATE_RIGHT: + case XUI_CONTROL_NAVIGATE_UP: + case XUI_CONTROL_NAVIGATE_DOWN: + pControlNavigateData->hObjDest = pControlNavigateData->hObjSource; + break; + } + + return 0; } HRESULT CRetroArchQuickMenu::OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled ) @@ -348,95 +425,70 @@ HRESULT CRetroArchQuickMenu::OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled { case MENU_ITEM_LOAD_STATE: if (g_console.emulator_initialized) - { + { rarch_load_state(); - return_to_game(); - } - break; + rarch_settings_change(S_RETURN_TO_GAME); + } + break; case MENU_ITEM_SAVE_STATE: if (g_console.emulator_initialized) { - rarch_save_state(); - return_to_game(); + rarch_save_state(); + rarch_settings_change(S_RETURN_TO_GAME); } break; case MENU_ITEM_KEEP_ASPECT_RATIO: - { - g_console.aspect_ratio_index++; - if(g_console.aspect_ratio_index >= ASPECT_RATIO_END) - g_console.aspect_ratio_index = 0; + { + rarch_settings_default(S_DEF_ASPECT_RATIO); - gfx_ctx_set_aspect_ratio(d3d9, g_console.aspect_ratio_index); - char aspectratio_label[32]; - snprintf(aspectratio_label, sizeof(aspectratio_label), "Aspect Ratio: %s", aspectratio_lut[g_console.aspect_ratio_index].name); - wchar_t * aspectratio_label_w = rarch_convert_char_to_wchar(aspectratio_label); - m_quickmenulist.SetText(MENU_ITEM_KEEP_ASPECT_RATIO, aspectratio_label_w); - free(aspectratio_label_w); - } + gfx_ctx_set_aspect_ratio(d3d9, g_console.aspect_ratio_index); + rarch_settings_create_menu_item_label(strw_buffer, S_LBL_ASPECT_RATIO, sizeof(strw_buffer)); + m_quickmenulist.SetText(MENU_ITEM_KEEP_ASPECT_RATIO, strw_buffer); + } break; case MENU_ITEM_OVERSCAN_AMOUNT: - msg_queue_clear(g_extern.msg_queue); - msg_queue_push(g_extern.msg_queue, "TODO - Not yet implemented.", 1, 180); + if(g_console.info_msg_enable) + rarch_settings_msg(S_MSG_NOT_IMPLEMENTED, S_DELAY_180); break; case MENU_ITEM_ORIENTATION: - switch(g_console.screen_orientation) - { - case ORIENTATION_NORMAL: - g_console.screen_orientation = ORIENTATION_VERTICAL; - m_quickmenulist.SetText(MENU_ITEM_ORIENTATION, L"Orientation: Vertical"); - break; - case ORIENTATION_VERTICAL: - g_console.screen_orientation = ORIENTATION_FLIPPED; - m_quickmenulist.SetText(MENU_ITEM_ORIENTATION, L"Orientation: Flipped"); - break; - case ORIENTATION_FLIPPED: - g_console.screen_orientation = ORIENTATION_FLIPPED_ROTATED; - m_quickmenulist.SetText(MENU_ITEM_ORIENTATION, L"Orientation: Flipped Rotated"); - break; - case ORIENTATION_FLIPPED_ROTATED: - g_console.screen_orientation = ORIENTATION_NORMAL; - m_quickmenulist.SetText(MENU_ITEM_ORIENTATION, L"Orientation: Normal"); - break; - } + rarch_settings_default(S_DEF_ROTATION); + rarch_settings_create_menu_item_label(strw_buffer, S_LBL_ROTATION, sizeof(strw_buffer)); + m_quickmenulist.SetText(MENU_ITEM_ORIENTATION, strw_buffer); video_xdk360.set_rotation(driver.video_data, g_console.screen_orientation); break; case MENU_ITEM_RESIZE_MODE: - g_console.input_loop = INPUT_LOOP_RESIZE_MODE; - msg_queue_clear(g_extern.msg_queue); - msg_queue_push(g_extern.msg_queue, "INFO - Resize the screen by moving around the two analog sticks.\nPress Y to reset to default values, and B to go back.\nTo select the resized screen mode, set Aspect Ratio to: 'Custom'.", 1, 270); + g_console.input_loop = INPUT_LOOP_RESIZE_MODE; + if (g_console.info_msg_enable) + rarch_settings_msg(S_MSG_RESIZE_SCREEN, S_DELAY_270); break; case MENU_ITEM_FRAME_ADVANCE: if (g_console.emulator_initialized) - { - g_console.frame_advance_enable = true; - g_console.menu_enable = false; - g_console.mode_switch = MODE_EMULATION; - } + rarch_settings_change(S_FRAME_ADVANCE); break; case MENU_ITEM_SCREENSHOT_MODE: - msg_queue_clear(g_extern.msg_queue); - msg_queue_push(g_extern.msg_queue, "TODO - Not yet implemented.", 1, 180); + if (g_console.info_msg_enable) + rarch_settings_msg(S_MSG_NOT_IMPLEMENTED, S_DELAY_180); break; case MENU_ITEM_RESET: if (g_console.emulator_initialized) { - return_to_game(); - rarch_game_reset(); + rarch_settings_change(S_RETURN_TO_GAME); + rarch_game_reset(); } break; case MENU_ITEM_RETURN_TO_GAME: if (g_console.emulator_initialized) - return_to_game(); + rarch_settings_change(S_RETURN_TO_GAME); break; case MENU_ITEM_RETURN_TO_DASHBOARD: - return_to_dashboard(); + rarch_settings_change(S_RETURN_TO_DASHBOARD); break; } } bHandled = TRUE; - return S_OK; + return 0; } HRESULT CRetroArchMain::OnInit(XUIMessageInit * pInitData, BOOL& bHandled) @@ -457,22 +509,17 @@ HRESULT CRetroArchMain::OnInit(XUIMessageInit * pInitData, BOOL& bHandled) char core_text[256]; snprintf(core_text, sizeof(core_text), "%s (v%s)", id, info.library_version); - char package_version[32]; - snprintf(package_version, sizeof(core_text), "RetroArch %s", PACKAGE_VERSION); + rarch_convert_char_to_wchar(strw_buffer, core_text, sizeof(strw_buffer)); + m_core.SetText(strw_buffer); + rarch_settings_create_menu_item_label(strw_buffer, S_LBL_RARCH_VERSION, sizeof(strw_buffer)); + m_title.SetText(strw_buffer); - wchar_t * core_text_utf = rarch_convert_char_to_wchar(core_text); - wchar_t * package_version_utf = rarch_convert_char_to_wchar(package_version); - m_core.SetText(core_text_utf); - m_title.SetText(package_version_utf); - free(core_text_utf); - free(package_version_utf); - - return S_OK; + return 0; } HRESULT CRetroArchFileBrowser::OnNotifyPress( HXUIOBJ hObjPressed, BOOL& bHandled ) { - char path[MAX_PATH_LENGTH]; + char path[PATH_MAX]; if(hObjPressed == m_romlist) { @@ -483,7 +530,7 @@ HRESULT CRetroArchFileBrowser::OnNotifyPress( HXUIOBJ hObjPressed, BOOL& bHandle retro_get_system_info(&info); bool block_zip_extract = info.block_extract; - const char * strbuffer = rarch_convert_wchar_to_const_char((const wchar_t*)m_romlist.GetText(index)); + const char * strbuffer = rarch_convert_wchar_to_const_char((const wchar_t*)m_romlist.GetText(index)); if((strstr(strbuffer, ".zip") || strstr(strbuffer, ".ZIP")) && !block_zip_extract) { @@ -495,8 +542,7 @@ HRESULT CRetroArchFileBrowser::OnNotifyPress( HXUIOBJ hObjPressed, BOOL& bHandle { memset(g_console.rom_path, 0, sizeof(g_console.rom_path)); snprintf(g_console.rom_path, sizeof(g_console.rom_path), "%s\\%s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(browser), strbuffer); - return_to_game(); - g_console.initialize_rarch_enable = 1; + rarch_settings_change(S_START_RARCH); } } else if(browser.cur[index].d_type == FILE_ATTRIBUTE_DIRECTORY) @@ -516,80 +562,79 @@ HRESULT CRetroArchFileBrowser::OnNotifyPress( HXUIOBJ hObjPressed, BOOL& bHandle { filebrowser_new(&browser, "cache:", rarch_console_get_rom_ext()); filebrowser_fetch_directory_entries("cache:", &browser, &m_romlist, &m_rompathtitle); - msg_queue_clear(g_extern.msg_queue); - msg_queue_push(g_extern.msg_queue, "INFO - All the contents of the ZIP files you have selected in the filebrowser\nare extracted to this partition.", 1, 180); + if (g_console.info_msg_enable) + rarch_settings_msg(S_MSG_CACHE_PARTITION, S_DELAY_180); } bHandled = TRUE; - return S_OK; + return 0; } HRESULT CRetroArchShaderBrowser::OnNotifyPress( HXUIOBJ hObjPressed, BOOL& bHandled ) { - char path[MAX_PATH_LENGTH]; + char path[PATH_MAX]; if(hObjPressed == m_shaderlist) { int index = m_shaderlist.GetCurSel(); if(tmp_browser.cur[index].d_type != FILE_ATTRIBUTE_DIRECTORY) { - const char * strbuffer = rarch_convert_wchar_to_const_char((const wchar_t *)m_shaderlist.GetText(index)); - - switch(set_shader) - { - case 1: - snprintf(g_settings.video.cg_shader_path, sizeof(g_settings.video.cg_shader_path), "%s\\%s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(tmp_browser), strbuffer); + const char * strbuffer = rarch_convert_wchar_to_const_char((const wchar_t *)m_shaderlist.GetText(index)); + + switch(set_shader) + { + case 1: + snprintf(g_settings.video.cg_shader_path, sizeof(g_settings.video.cg_shader_path), "%s\\%s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(tmp_browser), strbuffer); hlsl_load_shader(set_shader, g_settings.video.cg_shader_path); break; - case 2: - snprintf (g_settings.video.second_pass_shader, sizeof(g_settings.video.second_pass_shader), "%s\\%s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(tmp_browser), strbuffer); + case 2: + snprintf (g_settings.video.second_pass_shader, sizeof(g_settings.video.second_pass_shader), "%s\\%s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(tmp_browser), strbuffer); hlsl_load_shader(set_shader, g_settings.video.second_pass_shader); - break; - default: - break; - } - msg_queue_clear(g_extern.msg_queue); - msg_queue_push(g_extern.msg_queue, "INFO - Shader successfully loaded.", 1, 180); + break; + default: + break; + } + + if (g_console.info_msg_enable) + rarch_settings_msg(S_MSG_SHADER_LOADING_SUCCEEDED, S_DELAY_180); } else if(tmp_browser.cur[index].d_type == FILE_ATTRIBUTE_DIRECTORY) { - const char * strbuffer = rarch_convert_wchar_to_const_char((const wchar_t *)m_shaderlist.GetText(index)); - snprintf(path, sizeof(path), "%s\\%s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(tmp_browser), strbuffer); - filebrowser_fetch_directory_entries(path, &tmp_browser, &m_shaderlist, &m_shaderpathtitle); + const char * strbuffer = rarch_convert_wchar_to_const_char((const wchar_t *)m_shaderlist.GetText(index)); + snprintf(path, sizeof(path), "%s\\%s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(tmp_browser), strbuffer); + filebrowser_fetch_directory_entries(path, &tmp_browser, &m_shaderlist, &m_shaderpathtitle); } } bHandled = TRUE; - return S_OK; + return 0; } HRESULT CRetroArchCoreBrowser::OnNotifyPress( HXUIOBJ hObjPressed, BOOL& bHandled ) { - char path[MAX_PATH_LENGTH]; + char path[PATH_MAX]; if(hObjPressed == m_romlist) { int index = m_romlist.GetCurSel(); if(tmp_browser.cur[index].d_type != FILE_ATTRIBUTE_DIRECTORY) { - const char * strbuffer = rarch_convert_wchar_to_const_char((const wchar_t *)m_romlist.GetText(index)); - snprintf(g_console.launch_app_on_exit, sizeof(g_console.launch_app_on_exit), "%s\\%s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(tmp_browser), strbuffer); - g_console.return_to_launcher = true; - g_console.menu_enable = false; - g_console.mode_switch = MODE_EXIT; + const char * strbuffer = rarch_convert_wchar_to_const_char((const wchar_t *)m_romlist.GetText(index)); + snprintf(g_console.launch_app_on_exit, sizeof(g_console.launch_app_on_exit), "%s\\%s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(tmp_browser), strbuffer); + rarch_settings_change(S_RETURN_TO_LAUNCHER); } else if(tmp_browser.cur[index].d_type == FILE_ATTRIBUTE_DIRECTORY) { - const char * strbuffer = rarch_convert_wchar_to_const_char((const wchar_t *)m_romlist.GetText(index)); - snprintf(path, sizeof(path), "%s%s\\", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(tmp_browser), strbuffer); - filebrowser_fetch_directory_entries(path, &tmp_browser, &m_romlist, &m_rompathtitle); + const char * strbuffer = rarch_convert_wchar_to_const_char((const wchar_t *)m_romlist.GetText(index)); + snprintf(path, sizeof(path), "%s%s\\", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(tmp_browser), strbuffer); + filebrowser_fetch_directory_entries(path, &tmp_browser, &m_romlist, &m_rompathtitle); } } bHandled = TRUE; - return S_OK; + return 0; } HRESULT CRetroArchSettings::OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled ) @@ -604,74 +649,83 @@ HRESULT CRetroArchSettings::OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled switch(current_index) { case SETTING_EMU_REWIND_ENABLED: - g_settings.rewind_enable = !g_settings.rewind_enable; - m_settingslist.SetText(SETTING_EMU_REWIND_ENABLED, g_settings.rewind_enable ? L"Rewind: ON" : L"Rewind: OFF"); - msg_queue_clear(g_extern.msg_queue); - msg_queue_push(g_extern.msg_queue, "INFO - You need to restart RetroArch for this change to take effect.", 1, 180); + rarch_settings_change(S_REWIND); + m_settingslist.SetText(SETTING_EMU_REWIND_ENABLED, g_settings.rewind_enable ? L"Rewind: ON" : L"Rewind: OFF"); + + if (g_console.info_msg_enable) + rarch_settings_msg(S_MSG_RESTART_RARCH, S_DELAY_180); + break; + case SETTING_EMU_SHOW_INFO_MSG: + g_console.info_msg_enable = !g_console.info_msg_enable; + m_settingslist.SetText(SETTING_EMU_SHOW_INFO_MSG, g_console.info_msg_enable ? L"Info messages: ON" : L"Info messages: OFF"); + break; + case SETTING_EMU_MENUS: + g_console.menus_hd_enable = !g_console.menus_hd_enable; + m_settingslist.SetText(SETTING_EMU_MENUS, g_console.menus_hd_enable ? L"Menus: HD" : L"Menus: SD"); break; case SETTING_GAMMA_CORRECTION_ENABLED: g_console.gamma_correction_enable = !g_console.gamma_correction_enable; m_settingslist.SetText(SETTING_GAMMA_CORRECTION_ENABLED, g_console.gamma_correction_enable ? L"Gamma correction: ON" : L"Gamma correction: OFF"); - msg_queue_clear(g_extern.msg_queue); - msg_queue_push(g_extern.msg_queue, "INFO - You need to restart RetroArch for this change to take effect.", 1, 180); + if(g_console.info_msg_enable) + rarch_settings_msg(S_MSG_RESTART_RARCH, S_DELAY_180); break; case SETTING_COLOR_FORMAT: - g_console.color_format = !g_console.color_format; + g_console.color_format = !g_console.color_format; m_settingslist.SetText(SETTING_COLOR_FORMAT, g_console.color_format ? L"Color format: 32bit ARGB" : L"Color format: 16bit RGBA"); - msg_queue_clear(g_extern.msg_queue); - msg_queue_push(g_extern.msg_queue, "INFO - You need to restart RetroArch for this change to take effect.", 1, 180); - break; + if(g_console.info_msg_enable) + rarch_settings_msg(S_MSG_RESTART_RARCH, S_DELAY_180); + break; case SETTING_SHADER: - set_shader = 1; - hr = XuiSceneCreate(hdmenus_allowed ? L"file://game:/media/hd/" : L"file://game:/media/sd/", L"rarch_shader_browser.xur", NULL, &app.hShaderBrowser); + set_shader = 1; + hr = XuiSceneCreate(g_console.menus_hd_enable ? L"file://game:/media/hd/" : L"file://game:/media/sd/", L"rarch_shader_browser.xur", NULL, &app.hShaderBrowser); - if (FAILED(hr)) - { - RARCH_ERR("Failed to load scene.\n"); - } - hCur = app.hShaderBrowser; - msg_queue_clear(g_extern.msg_queue); - msg_queue_push(g_extern.msg_queue, "INFO - Select a shader from the menu by pressing the A button.", 1, 180); - NavigateForward(app.hShaderBrowser); - break; + if (hr < 0) + { + RARCH_ERR("Failed to load scene.\n"); + } + hCur = app.hShaderBrowser; + + if (g_console.info_msg_enable) + rarch_settings_msg(S_MSG_SELECT_SHADER, S_DELAY_180); + NavigateForward(app.hShaderBrowser); + break; case SETTING_SHADER_2: - set_shader = 2; - hr = XuiSceneCreate(hdmenus_allowed ? L"file://game:/media/hd/" : L"file://game:/media/sd/", L"rarch_shader_browser.xur", NULL, &app.hShaderBrowser); - - if (FAILED(hr)) - { - RARCH_ERR("Failed to load scene.\n"); - } - hCur = app.hShaderBrowser; - msg_queue_clear(g_extern.msg_queue); - msg_queue_push(g_extern.msg_queue, "INFO - Select a shader from the menu by pressing the A button.", 1, 180); - NavigateForward(app.hShaderBrowser); - break; + set_shader = 2; + hr = XuiSceneCreate(g_console.menus_hd_enable ? L"file://game:/media/hd/" : L"file://game:/media/sd/", L"rarch_shader_browser.xur", NULL, &app.hShaderBrowser); + if (hr < 0) + { + RARCH_ERR("Failed to load scene.\n"); + } + hCur = app.hShaderBrowser; + if (g_console.info_msg_enable) + rarch_settings_msg(S_MSG_SELECT_SHADER, S_DELAY_180); + NavigateForward(app.hShaderBrowser); + break; case SETTING_HW_TEXTURE_FILTER: g_settings.video.smooth = !g_settings.video.smooth; - m_settingslist.SetText(SETTING_HW_TEXTURE_FILTER, g_settings.video.smooth ? L"Hardware filtering shader #1: Linear interpolation" : L"Hardware filtering shader #1: Point filtering"); + m_settingslist.SetText(SETTING_HW_TEXTURE_FILTER, g_settings.video.smooth ? L"Hardware filtering shader #1: Linear interpolation" : L"Hardware filtering shader #1: Point filtering"); break; case SETTING_HW_TEXTURE_FILTER_2: g_settings.video.second_pass_smooth = !g_settings.video.second_pass_smooth; - m_settingslist.SetText(SETTING_HW_TEXTURE_FILTER_2, g_settings.video.second_pass_smooth ? L"Hardware filtering shader #2: Linear interpolation" : L"Hardware filtering shader #2: Point filtering"); + m_settingslist.SetText(SETTING_HW_TEXTURE_FILTER_2, g_settings.video.second_pass_smooth ? L"Hardware filtering shader #2: Linear interpolation" : L"Hardware filtering shader #2: Point filtering"); break; case SETTING_SCALE_ENABLED: - g_console.fbo_enabled = !g_console.fbo_enabled; - m_settingslist.SetText(SETTING_SCALE_ENABLED, g_console.fbo_enabled ? L"Custom Scaling/Dual Shaders: ON" : L"Custom Scaling/Dual Shaders: OFF"); - gfx_ctx_set_fbo(g_console.fbo_enabled); - break; + g_console.fbo_enabled = !g_console.fbo_enabled; + m_settingslist.SetText(SETTING_SCALE_ENABLED, g_console.fbo_enabled ? L"Custom Scaling/Dual Shaders: ON" : L"Custom Scaling/Dual Shaders: OFF"); + gfx_ctx_set_fbo(g_console.fbo_enabled); + break; } } bHandled = TRUE; - return S_OK; + return 0; } HRESULT CRetroArchMain::OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled ) { xdk360_video_t *vid = (xdk360_video_t*)driver.video_data; - hdmenus_allowed = vid->video_mode.fIsHiDef && (g_console.aspect_ratio_index >= ASPECT_RATIO_16_9); + bool hdmenus_allowed = g_console.menus_hd_enable; HRESULT hr; @@ -679,60 +733,63 @@ HRESULT CRetroArchMain::OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled ) { hr = XuiSceneCreate(hdmenus_allowed ? L"file://game:/media/hd/" : L"file://game:/media/sd/", L"rarch_filebrowser.xur", NULL, &app.hFileBrowser); - if (FAILED(hr)) - { + if (hr < 0) RARCH_ERR("Failed to load scene.\n"); - } - hCur = app.hFileBrowser; + + hCur = app.hFileBrowser; NavigateForward(app.hFileBrowser); } else if ( hObjPressed == m_quick_menu) { hr = XuiSceneCreate(hdmenus_allowed ? L"file://game:/media/hd/" : L"file://game:/media/sd/", L"rarch_quickmenu.xur", NULL, &app.hQuickMenu); - if (FAILED(hr)) + if (hr < 0) RARCH_ERR("Failed to load scene.\n"); - hCur = app.hQuickMenu; + + hCur = app.hQuickMenu; NavigateForward(app.hQuickMenu); } else if ( hObjPressed == m_controls) { hr = XuiSceneCreate(hdmenus_allowed ? L"file://game:/media/hd/" : L"file://game:/media/sd/", L"rarch_controls.xur", NULL, &app.hControlsMenu); - if (FAILED(hr)) + if (hr < 0) RARCH_ERR("Failed to load scene.\n"); - hCur = app.hControlsMenu; - msg_queue_clear(g_extern.msg_queue); - msg_queue_push(g_extern.msg_queue, "INFO - Press LEFT/RIGHT to change the controls, and press\nSTART/A to reset a button to default values.", 1, 180); + + hCur = app.hControlsMenu; + if (g_console.info_msg_enable) + rarch_settings_msg(S_MSG_CHANGE_CONTROLS, S_DELAY_180); NavigateForward(app.hControlsMenu); } else if ( hObjPressed == m_change_libretro_core ) { hr = XuiSceneCreate(hdmenus_allowed ? L"file://game:/media/hd/" : L"file://game:/media/sd/", L"rarch_libretrocore_browser.xur", NULL, &app.hCoreBrowser); - if (FAILED(hr)) + if (hr < 0) { RARCH_ERR("Failed to load scene.\n"); } - hCur = app.hCoreBrowser; - msg_queue_clear(g_extern.msg_queue); - msg_queue_push(g_extern.msg_queue, "INFO - Select a Libretro core from the menu by pressing the A button.", 1, 180); + hCur = app.hCoreBrowser; + + if (g_console.info_msg_enable) + rarch_settings_msg(S_MSG_SELECT_LIBRETRO_CORE, S_DELAY_180); NavigateForward(app.hCoreBrowser); } else if ( hObjPressed == m_settings ) { hr = XuiSceneCreate(hdmenus_allowed ? L"file://game:/media/hd/" : L"file://game:/media/sd/", L"rarch_settings.xur", NULL, &app.hRetroArchSettings); - if (FAILED(hr)) + if (hr < 0) RARCH_ERR("Failed to load scene.\n"); - hCur = app.hRetroArchSettings; + + hCur = app.hRetroArchSettings; NavigateForward(app.hRetroArchSettings); } else if ( hObjPressed == m_quit ) - return_to_dashboard(); + rarch_settings_change(S_RETURN_TO_DASHBOARD); bHandled = TRUE; - return S_OK; + return 0; } int menu_init (void) @@ -743,7 +800,7 @@ int menu_init (void) hr = app.InitShared(vid->d3d_render_device, &vid->d3dpp, XuiPNGTextureLoader); - if (FAILED(hr)) + if (hr < 0) { RARCH_ERR("Failed initializing XUI application.\n"); return 1; @@ -751,21 +808,21 @@ int menu_init (void) /* Register font */ hr = app.RegisterDefaultTypeface(L"Arial Unicode MS", L"file://game:/media/rarch.ttf" ); - if (FAILED(hr)) + if (hr < 0) { RARCH_ERR("Failed to register default typeface.\n"); return 1; } hr = app.LoadSkin( L"file://game:/media/rarch_scene_skin.xur"); - if (FAILED(hr)) + if (hr < 0) { RARCH_ERR("Failed to load skin.\n"); return 1; } hr = XuiSceneCreate(L"file://game:/media/sd/", L"rarch_main.xur", NULL, &app.hMainScene); - if (FAILED(hr)) + if (hr < 0) { RARCH_ERR("Failed to create scene 'rarch_main.xur'.\n"); return 1; @@ -781,7 +838,7 @@ int menu_init (void) void menu_deinit (void) { - app.Uninit(); + app.Uninit(); } void menu_loop(void) @@ -797,29 +854,38 @@ void menu_loop(void) do { - rarch_render_cached_frame(); + if(g_console.emulator_initialized) + { + rarch_render_cached_frame(); + } + else + { + d3d9->d3d_render_device->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0, 0, 0, 0), 1.0f, 0); + d3d9->frame_count++; + } XINPUT_STATE state; XInputGetState(0, &state); g_console.menu_enable = !((state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB) - && (state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB) && (g_console.emulator_initialized) - && IS_TIMER_EXPIRED(d3d9)); + && (state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB) && (g_console.emulator_initialized) + && IS_TIMER_EXPIRED(d3d9)); + g_console.mode_switch = g_console.menu_enable ? MODE_MENU : MODE_EMULATION; - switch(g_console.input_loop) - { + switch(g_console.input_loop) + { case INPUT_LOOP_MENU: - app.RunFrame(); /* Update XUI */ + app.RunFrame(); /* Update XUI */ if(state.Gamepad.wButtons & XINPUT_GAMEPAD_B && hCur != app.hMainScene) XuiSceneNavigateBack(hCur, app.hMainScene, XUSER_INDEX_ANY); break; - case INPUT_LOOP_RESIZE_MODE: - xdk360_input_loop(); - break; - default: - break; - } + case INPUT_LOOP_RESIZE_MODE: + xdk360_input_loop(); + break; + default: + break; + } hr = app.Render(); /* Render XUI */ hr = XuiTimersRun(); /* Update XUI timers */ @@ -829,22 +895,17 @@ void menu_loop(void) SET_TIMER_EXPIRATION(d3d9, 30); } - /* XBox 360 specific font code */ - { - const char *msg = msg_queue_pull(g_extern.msg_queue); + const char *message = msg_queue_pull(g_extern.msg_queue); - if (msg) + if (message) + { + if(IS_TIMER_EXPIRED(d3d9)) { - if(IS_TIMER_EXPIRED(d3d9) || g_first_msg) - { - xdk360_console_format(msg); - g_first_msg = 0; - SET_TIMER_EXPIRATION(d3d9, 30); - } - - xdk360_console_draw(); + xdk360_console_format(message); + SET_TIMER_EXPIRATION(d3d9, 30); } - } + xdk360_console_draw(); + } gfx_ctx_swap_buffers(); }while(g_console.menu_enable); diff --git a/360/menu.h b/360/menu.h index fed2d54ca8..fbb3978eea 100644 --- a/360/menu.h +++ b/360/menu.h @@ -23,6 +23,8 @@ enum { SETTING_EMU_REWIND_ENABLED = 0, + SETTING_EMU_SHOW_INFO_MSG, + SETTING_EMU_MENUS, SETTING_GAMMA_CORRECTION_ENABLED, SETTING_COLOR_FORMAT, SETTING_SHADER, @@ -35,23 +37,23 @@ enum enum { - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_B = 0, - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_Y, - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_SELECT, - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_START, - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_UP, - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_DOWN, - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_LEFT, - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_RIGHT, - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_A, - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_X, - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_L, - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_R, - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_L2, - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_R2, - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_L3, - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_R3, - SETTING_CONTROLS_DEFAULT_ALL + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_B = 0, + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_Y, + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_SELECT, + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_START, + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_UP, + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_DOWN, + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_LEFT, + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_RIGHT, + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_A, + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_X, + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_L, + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_R, + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_L2, + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_R2, + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_L3, + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_R3, + SETTING_CONTROLS_DEFAULT_ALL }; enum @@ -62,154 +64,154 @@ enum class CRetroArch : public CXuiModule { -public: - HXUIOBJ hMainScene; - HXUIOBJ hControlsMenu; - HXUIOBJ hFileBrowser; - HXUIOBJ hCoreBrowser; - HXUIOBJ hShaderBrowser; - HXUIOBJ hQuickMenu; - HXUIOBJ hRetroArchSettings; -protected: - /* Override so that Cssnes can register classes */ - virtual HRESULT RegisterXuiClasses(); - /* Override so that Cssnes can unregister classes */ - virtual HRESULT UnregisterXuiClasses(); + public: + HXUIOBJ hMainScene; + HXUIOBJ hControlsMenu; + HXUIOBJ hFileBrowser; + HXUIOBJ hCoreBrowser; + HXUIOBJ hShaderBrowser; + HXUIOBJ hQuickMenu; + HXUIOBJ hRetroArchSettings; + protected: + virtual HRESULT RegisterXuiClasses(); + virtual HRESULT UnregisterXuiClasses(); }; class CRetroArchMain: public CXuiSceneImpl { -protected: - CXuiControl m_filebrowser; - CXuiControl m_quick_menu; - CXuiControl m_controls; - CXuiControl m_settings; - CXuiControl m_change_libretro_core; - CXuiControl m_quit; - CXuiTextElement m_title; - CXuiTextElement m_core; -public: - HRESULT OnInit( XUIMessageInit* pInitData, int & bHandled ); - HRESULT OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled ); + protected: + CXuiControl m_filebrowser; + CXuiControl m_quick_menu; + CXuiControl m_controls; + CXuiControl m_settings; + CXuiControl m_change_libretro_core; + CXuiControl m_quit; + CXuiTextElement m_title; + CXuiTextElement m_core; + public: + HRESULT OnInit( XUIMessageInit* pInitData, int & bHandled ); + HRESULT OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled ); - XUI_BEGIN_MSG_MAP() - XUI_ON_XM_INIT( OnInit) - XUI_ON_XM_NOTIFY_PRESS( OnNotifyPress ) - XUI_END_MSG_MAP(); + XUI_BEGIN_MSG_MAP() + XUI_ON_XM_INIT( OnInit) + XUI_ON_XM_NOTIFY_PRESS( OnNotifyPress ) + XUI_END_MSG_MAP(); - XUI_IMPLEMENT_CLASS(CRetroArchMain, L"RetroArchMain", XUI_CLASS_SCENE) + XUI_IMPLEMENT_CLASS(CRetroArchMain, L"RetroArchMain", XUI_CLASS_SCENE) }; class CRetroArchFileBrowser: public CXuiSceneImpl { -protected: - CXuiList m_romlist; - CXuiControl m_back; - CXuiControl m_dir_game; - CXuiControl m_dir_cache; - CXuiTextElement m_rompathtitle; -public: - HRESULT OnInit( XUIMessageInit* pInitData, int & bHandled ); - HRESULT OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled ); + protected: + CXuiList m_romlist; + CXuiControl m_back; + CXuiControl m_dir_game; + CXuiControl m_dir_cache; + CXuiTextElement m_rompathtitle; + public: + HRESULT OnInit( XUIMessageInit* pInitData, int & bHandled ); + HRESULT OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled ); - XUI_BEGIN_MSG_MAP() - XUI_ON_XM_INIT( OnInit) - XUI_ON_XM_NOTIFY_PRESS( OnNotifyPress ) - XUI_END_MSG_MAP(); + XUI_BEGIN_MSG_MAP() + XUI_ON_XM_INIT( OnInit) + XUI_ON_XM_NOTIFY_PRESS( OnNotifyPress ) + XUI_END_MSG_MAP(); - XUI_IMPLEMENT_CLASS(CRetroArchFileBrowser, L"RetroArchFileBrowser", XUI_CLASS_SCENE) + XUI_IMPLEMENT_CLASS(CRetroArchFileBrowser, L"RetroArchFileBrowser", XUI_CLASS_SCENE) }; class CRetroArchCoreBrowser: public CXuiSceneImpl { -protected: - CXuiList m_romlist; - CXuiControl m_back; - CXuiTextElement m_rompathtitle; -public: - HRESULT OnInit( XUIMessageInit* pInitData, int & bHandled ); - HRESULT OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled ); + protected: + CXuiList m_romlist; + CXuiControl m_back; + CXuiTextElement m_rompathtitle; + public: + HRESULT OnInit( XUIMessageInit* pInitData, int & bHandled ); + HRESULT OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled ); - XUI_BEGIN_MSG_MAP() - XUI_ON_XM_INIT( OnInit) - XUI_ON_XM_NOTIFY_PRESS( OnNotifyPress ) - XUI_END_MSG_MAP(); + XUI_BEGIN_MSG_MAP() + XUI_ON_XM_INIT( OnInit) + XUI_ON_XM_NOTIFY_PRESS( OnNotifyPress ) + XUI_END_MSG_MAP(); - XUI_IMPLEMENT_CLASS(CRetroArchCoreBrowser, L"RetroArchCoreBrowser", XUI_CLASS_SCENE) + XUI_IMPLEMENT_CLASS(CRetroArchCoreBrowser, L"RetroArchCoreBrowser", XUI_CLASS_SCENE) }; class CRetroArchShaderBrowser: public CXuiSceneImpl { -protected: - CXuiList m_shaderlist; - CXuiControl m_back; - CXuiTextElement m_shaderpathtitle; -public: - HRESULT OnInit( XUIMessageInit* pInitData, int & bHandled ); - HRESULT OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled ); + protected: + CXuiList m_shaderlist; + CXuiControl m_back; + CXuiTextElement m_shaderpathtitle; + public: + HRESULT OnInit( XUIMessageInit* pInitData, int & bHandled ); + HRESULT OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled ); - XUI_BEGIN_MSG_MAP() - XUI_ON_XM_INIT( OnInit) - XUI_ON_XM_NOTIFY_PRESS( OnNotifyPress ) - XUI_END_MSG_MAP(); + XUI_BEGIN_MSG_MAP() + XUI_ON_XM_INIT( OnInit) + XUI_ON_XM_NOTIFY_PRESS( OnNotifyPress ) + XUI_END_MSG_MAP(); - XUI_IMPLEMENT_CLASS(CRetroArchShaderBrowser, L"RetroArchShaderBrowser", XUI_CLASS_SCENE) + XUI_IMPLEMENT_CLASS(CRetroArchShaderBrowser, L"RetroArchShaderBrowser", XUI_CLASS_SCENE) }; class CRetroArchQuickMenu: public CXuiSceneImpl { -protected: - CXuiList m_quickmenulist; - CXuiControl m_back; -public: - HRESULT OnInit( XUIMessageInit* pInitData, int & bHandled ); - HRESULT OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled ); + protected: + CXuiList m_quickmenulist; + CXuiControl m_back; + public: + HRESULT OnInit( XUIMessageInit* pInitData, int & bHandled ); + HRESULT OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled ); + HRESULT OnControlNavigate(XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled); - XUI_BEGIN_MSG_MAP() - XUI_ON_XM_INIT( OnInit) - XUI_ON_XM_NOTIFY_PRESS( OnNotifyPress ) - XUI_END_MSG_MAP(); + XUI_BEGIN_MSG_MAP() + XUI_ON_XM_INIT( OnInit) + XUI_ON_XM_CONTROL_NAVIGATE( OnControlNavigate ) + XUI_ON_XM_NOTIFY_PRESS( OnNotifyPress ) + XUI_END_MSG_MAP(); - XUI_IMPLEMENT_CLASS(CRetroArchQuickMenu, L"RetroArchQuickMenu", XUI_CLASS_SCENE) + XUI_IMPLEMENT_CLASS(CRetroArchQuickMenu, L"RetroArchQuickMenu", XUI_CLASS_SCENE) }; class CRetroArchSettings: public CXuiSceneImpl { -protected: - CXuiList m_settingslist; - CXuiControl m_back; -public: - HRESULT OnInit( XUIMessageInit* pInitData, int & bHandled ); - HRESULT OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled ); - HRESULT OnControlNavigate(XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled); + protected: + CXuiList m_settingslist; + CXuiControl m_back; + public: + HRESULT OnInit( XUIMessageInit* pInitData, int & bHandled ); + HRESULT OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled ); + HRESULT OnControlNavigate(XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled); - XUI_BEGIN_MSG_MAP() - XUI_ON_XM_INIT( OnInit) - XUI_ON_XM_CONTROL_NAVIGATE( OnControlNavigate ) - XUI_ON_XM_NOTIFY_PRESS( OnNotifyPress ) - XUI_END_MSG_MAP(); + XUI_BEGIN_MSG_MAP() + XUI_ON_XM_INIT( OnInit) + XUI_ON_XM_CONTROL_NAVIGATE( OnControlNavigate ) + XUI_ON_XM_NOTIFY_PRESS( OnNotifyPress ) + XUI_END_MSG_MAP(); - XUI_IMPLEMENT_CLASS(CRetroArchSettings, L"RetroArchSettings", XUI_CLASS_SCENE) + XUI_IMPLEMENT_CLASS(CRetroArchSettings, L"RetroArchSettings", XUI_CLASS_SCENE) }; class CRetroArchControls: public CXuiSceneImpl { -protected: - CXuiList m_controlslist; - CXuiControl m_back; - CXuiSlider m_controlnoslider; -public: - HRESULT OnInit( XUIMessageInit* pInitData, int & bHandled ); - HRESULT OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled ); - HRESULT OnControlNavigate(XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled); + protected: + CXuiList m_controlslist; + CXuiControl m_back; + CXuiSlider m_controlnoslider; + public: + HRESULT OnInit( XUIMessageInit* pInitData, int & bHandled ); + HRESULT OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled ); + HRESULT OnControlNavigate(XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled); - XUI_BEGIN_MSG_MAP() - XUI_ON_XM_INIT( OnInit) - XUI_ON_XM_CONTROL_NAVIGATE( OnControlNavigate ) - XUI_ON_XM_NOTIFY_PRESS( OnNotifyPress ) - XUI_END_MSG_MAP(); + XUI_BEGIN_MSG_MAP() + XUI_ON_XM_INIT( OnInit) + XUI_ON_XM_CONTROL_NAVIGATE( OnControlNavigate ) + XUI_ON_XM_NOTIFY_PRESS( OnNotifyPress ) + XUI_END_MSG_MAP(); - XUI_IMPLEMENT_CLASS(CRetroArchControls, L"RetroArchControls", XUI_CLASS_SCENE) + XUI_IMPLEMENT_CLASS(CRetroArchControls, L"RetroArchControls", XUI_CLASS_SCENE) }; int menu_init (void); diff --git a/360/xdk360_input.c b/360/xdk360_input.c index ea9a249d6c..58a85c6940 100644 --- a/360/xdk360_input.c +++ b/360/xdk360_input.c @@ -22,7 +22,6 @@ #include "../libretro.h" #include "../console/console_ext.h" #include "xdk360_input.h" -#include "shared.h" #include "menu.h" static uint64_t state[4]; diff --git a/360/xdk360_video.cpp b/360/xdk360_video.cpp index c60539b3be..b13a42d827 100644 --- a/360/xdk360_video.cpp +++ b/360/xdk360_video.cpp @@ -14,7 +14,6 @@ * If not, see . */ -// Xbox 360-specific headers #ifdef _XBOX #include #include @@ -32,82 +31,79 @@ #include "../console/console_ext.h" #include "../general.h" #include "../message.h" -#include "shared.h" #ifdef HAVE_CONFIG_H #include "config.h" #endif -static bool g_first_msg; - /* Xbox 360 specific code */ 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, + 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, }; struct XPR_HEADER @@ -151,100 +147,101 @@ void * PackedResource::GetData( const char * strName ) const HRESULT PackedResource::Create( const char * strFilename ) { - unsigned long dwNumBytesRead; - HANDLE hFile = CreateFile( strFilename, GENERIC_READ, FILE_SHARE_READ, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL ); - if( hFile == INVALID_HANDLE_VALUE ) - { - RARCH_ERR( "File <%s> not found.\n", strFilename ); - return E_FAIL; - } + unsigned long dwNumBytesRead; + void * hFile = CreateFile( strFilename, GENERIC_READ, FILE_SHARE_READ, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL ); - // Read in and verify the XPR magic header - XPR_HEADER xprh; - if( !ReadFile( hFile, &xprh, sizeof( XPR_HEADER ), &dwNumBytesRead, NULL ) ) - { - RARCH_ERR( "Error reading XPR header in file <%s>.\n", strFilename ); - CloseHandle( hFile ); - return E_FAIL; - } + if( hFile == INVALID_HANDLE_VALUE ) + { + RARCH_ERR( "File <%s> not found.\n", strFilename ); + return E_FAIL; + } - if( xprh.dwMagic != XPR2_MAGIC_VALUE ) - { - RARCH_ERR( "Invalid Xbox Packed Resource (.xpr) file: Magic = 0x%08lx.\n", xprh.dwMagic ); - CloseHandle( hFile ); - return E_FAIL; - } + // Read in and verify the XPR magic header + XPR_HEADER xprh; + if( !ReadFile( hFile, &xprh, sizeof( XPR_HEADER ), &dwNumBytesRead, NULL ) ) + { + RARCH_ERR( "Error reading XPR header in file <%s>.\n", strFilename ); + CloseHandle( hFile ); + return E_FAIL; + } - // Compute memory requirements - m_dwSysMemDataSize = xprh.dwHeaderSize; - m_dwVidMemDataSize = xprh.dwDataSize; + if( xprh.dwMagic != XPR2_MAGIC_VALUE ) + { + RARCH_ERR( "Invalid Xbox Packed Resource (.xpr) file: Magic = 0x%08lx.\n", xprh.dwMagic ); + CloseHandle( hFile ); + return E_FAIL; + } - // Allocate memory - m_pSysMemData = (BYTE*)malloc(m_dwSysMemDataSize); - if( m_pSysMemData == NULL ) - { - RARCH_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_GameMax, - XALLOC_PHYSICAL_ALIGNMENT_4K, XALLOC_MEMPROTECT_WRITECOMBINE, 0, XALLOC_MEMTYPE_PHYSICAL ) ); + // Compute memory requirements + m_dwSysMemDataSize = xprh.dwHeaderSize; + m_dwVidMemDataSize = xprh.dwDataSize; - if( m_pVidMemData == NULL ) - { - RARCH_ERR( "Could not allocate physical memory.\n" ); - m_dwSysMemDataSize = 0; - m_dwVidMemDataSize = 0; - free(m_pSysMemData); - m_pSysMemData = NULL; - return E_FAIL; - } + // Allocate memory + m_pSysMemData = (unsigned char*)malloc(m_dwSysMemDataSize); + if( m_pSysMemData == NULL ) + { + RARCH_ERR( "Could not allocate system memory.\n" ); + m_dwSysMemDataSize = 0; + return E_FAIL; + } + m_pVidMemData = ( unsigned char* )XMemAlloc( m_dwVidMemDataSize, MAKE_XALLOC_ATTRIBUTES( 0, 0, 0, 0, eXALLOCAllocatorId_GameMax, + XALLOC_PHYSICAL_ALIGNMENT_4K, XALLOC_MEMPROTECT_WRITECOMBINE, 0, XALLOC_MEMTYPE_PHYSICAL ) ); - // Read in the data from the file - if( !ReadFile( hFile, m_pSysMemData, m_dwSysMemDataSize, &dwNumBytesRead, NULL ) || - !ReadFile( hFile, m_pVidMemData, m_dwVidMemDataSize, &dwNumBytesRead, NULL ) ) - { - RARCH_ERR( "Unable to read Xbox Packed Resource (.xpr) file.\n" ); - CloseHandle( hFile ); - return E_FAIL; - } + if( m_pVidMemData == NULL ) + { + RARCH_ERR( "Could not allocate physical memory.\n" ); + m_dwSysMemDataSize = 0; + m_dwVidMemDataSize = 0; + free(m_pSysMemData); + m_pSysMemData = NULL; + return E_FAIL; + } - // Done with the file - CloseHandle( hFile ); + // Read in the data from the file + if( !ReadFile( hFile, m_pSysMemData, m_dwSysMemDataSize, &dwNumBytesRead, NULL ) || + !ReadFile( hFile, m_pVidMemData, m_dwVidMemDataSize, &dwNumBytesRead, NULL ) ) + { + RARCH_ERR( "Unable to read Xbox Packed Resource (.xpr) file.\n" ); + CloseHandle( hFile ); + return E_FAIL; + } - // Extract resource table from the header data - m_dwNumResourceTags = *( unsigned long * )( m_pSysMemData + 0 ); - m_pResourceTags = ( RESOURCE* )( m_pSysMemData + 4 ); + // Done with the file + CloseHandle( hFile ); - // Patch up the resources - for( unsigned long i = 0; i < m_dwNumResourceTags; i++ ) - { - m_pResourceTags[i].strName = ( char * )( m_pSysMemData + ( unsigned long )m_pResourceTags[i].strName ); + // Extract resource table from the header data + m_dwNumResourceTags = *( unsigned long * )( m_pSysMemData + 0 ); + m_pResourceTags = ( RESOURCE* )( m_pSysMemData + 4 ); - // 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 ); - } - } + // Patch up the resources + for( unsigned long i = 0; i < m_dwNumResourceTags; i++ ) + { + m_pResourceTags[i].strName = ( char * )( m_pSysMemData + ( unsigned long )m_pResourceTags[i].strName ); - m_bInitialized = TRUE; + // 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 ); + } + } - return S_OK; + m_bInitialized = TRUE; + + return 0; } void PackedResource::Destroy() { - delete[] m_pSysMemData; + free(m_pSysMemData); m_pSysMemData = NULL; m_dwSysMemDataSize = 0L; if( m_pVidMemData != NULL ) - XMemFree( m_pVidMemData, MAKE_XALLOC_ATTRIBUTES( 0, 0, 0, 0, eXALLOCAllocatorId_GameMax, - 0, 0, 0, XALLOC_MEMTYPE_PHYSICAL ) ); + XMemFree( m_pVidMemData, MAKE_XALLOC_ATTRIBUTES( 0, 0, 0, 0, eXALLOCAllocatorId_GameMax, + 0, 0, 0, XALLOC_MEMTYPE_PHYSICAL ) ); m_pVidMemData = NULL; m_dwVidMemDataSize = 0L; @@ -297,7 +294,7 @@ static void xdk360_set_viewport(bool force_full) xdk360_video_t *d3d9 = (xdk360_video_t*)driver.video_data; d3d9->d3d_render_device->Clear(0, NULL, D3DCLEAR_TARGET, - 0xff000000, 1.0f, 0); + 0xff000000, 1.0f, 0); int width = d3d9->video_mode.fIsHiDef ? 1280 : 640; int height = d3d9->video_mode.fIsHiDef ? 720 : 480; @@ -321,7 +318,7 @@ static void xdk360_set_viewport(bool force_full) // If the aspect ratios of screen and desired aspect ratio are sufficiently equal (floating point stuff), if(g_console.aspect_ratio_index == ASPECT_RATIO_CUSTOM) { - delta = (desired_aspect / device_aspect - 1.0) / 2.0 + 0.5; + delta = (desired_aspect / device_aspect - 1.0) / 2.0 + 0.5; m_viewport_x_temp = g_console.viewports.custom_vp.x; m_viewport_y_temp = g_console.viewports.custom_vp.y; m_viewport_width_temp = g_console.viewports.custom_vp.width; @@ -370,7 +367,7 @@ static void xdk360_set_rotation(void * data, unsigned orientation) { case ORIENTATION_NORMAL: angle = M_PI * 0 / 180; - break; + break; case ORIENTATION_VERTICAL: angle = M_PI * 270 / 180; break; @@ -390,15 +387,15 @@ static void xdk360_set_rotation(void * data, unsigned orientation) 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; + pTexture->Format.SignX = GPUSIGN_GAMMA; + pTexture->Format.SignY = GPUSIGN_GAMMA; + pTexture->Format.SignZ = GPUSIGN_GAMMA; - XGTEXTURE_DESC desc; - XGGetTextureDesc( pTexture, 0, &desc ); + 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 ]; + //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) @@ -456,9 +453,12 @@ static void *xdk360_init(const video_info_t *video, const input_driver_t **input // unsupported if(!d3d9->video_mode.fIsWideScreen) d3d9->d3dpp.Flags |= D3DPRESENTFLAG_NO_LETTERBOX; + + g_console.menus_hd_enable = d3d9->video_mode.fIsHiDef; d3d9->d3dpp.BackBufferWidth = d3d9->video_mode.fIsHiDef ? 1280 : 640; d3d9->d3dpp.BackBufferHeight = d3d9->video_mode.fIsHiDef ? 720 : 480; + if(g_console.gamma_correction_enable) { d3d9->d3dpp.BackBufferFormat = g_console.color_format ? (D3DFORMAT)MAKESRGBFMT(D3DFMT_A8R8G8B8) : (D3DFORMAT)MAKESRGBFMT(D3DFMT_LIN_A1R5G5B5); @@ -646,7 +646,7 @@ static bool xdk360_frame(void *data, const void *frame, if(d3d9->fbo_enabled) { d3d9->d3d_render_device->Resolve(D3DRESOLVE_RENDERTARGET0, NULL, d3d9->lpTexture_ot, - NULL, 0, 0, NULL, 0, 0, NULL); + NULL, 0, 0, NULL, 0, 0, NULL); d3d9->d3d_render_device->SetRenderTarget(0, pRenderTarget0); pRenderTarget0->Release(); @@ -669,10 +669,9 @@ static bool xdk360_frame(void *data, const void *frame, /* XBox 360 specific font code */ if (msg && !menu_enabled) { - if(IS_TIMER_EXPIRED(d3d9) || g_first_msg) + if(IS_TIMER_EXPIRED(d3d9)) { xdk360_console_format(msg); - g_first_msg = 0; SET_TIMER_EXPIRATION(d3d9, 30); } @@ -709,11 +708,6 @@ static bool xdk360_focus(void *data) return gfx_ctx_window_has_focus(); } -// 360 needs a working graphics stack before RetroArch even starts. -// To deal with this main.c, -// the top level module owns the instance, and is created beforehand. -// When RetroArch gets around to init it, it is already allocated. -// When RetroArch wants to free it, it is ignored. static void xdk360_start(void) { video_info_t video_info = {0}; @@ -730,13 +724,11 @@ static void xdk360_start(void) gfx_ctx_set_swap_interval(d3d9->vsync ? 1 : 0, false); - g_first_msg = true; - /* XBox 360 specific font code */ HRESULT hr = xdk360_console_init("game:\\media\\Arial_12.xpr", 0xff000000, 0xffffffff ); - if(FAILED(hr)) + if(hr < 0) { RARCH_ERR("Couldn't create debug console.\n"); } diff --git a/360/xdk360_video.h b/360/xdk360_video.h index 8cca3cc9d1..508e3ab832 100644 --- a/360/xdk360_video.h +++ b/360/xdk360_video.h @@ -64,6 +64,4 @@ typedef struct xdk360_video LPDIRECT3DSURFACE9 lpSurface; } xdk360_video_t; -void xdk360_gfx_init_fbo(xdk360_video_t *vid); - #endif diff --git a/360/xdk360_video_resources.h b/360/xdk360_video_resources.h index 4196e3cb1f..bd75bb7140 100644 --- a/360/xdk360_video_resources.h +++ b/360/xdk360_video_resources.h @@ -19,11 +19,6 @@ #ifndef RARCH_360_RESOURCES_H #define RARCH_360_RESOURCES_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; @@ -50,73 +45,74 @@ enum //-------------------------------------------------------------------------------------- class PackedResource { -protected: - unsigned char * m_pSysMemData; // Alloc'ed memory for resource headers etc. - unsigned long m_dwSysMemDataSize; + 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; + 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 -public: - int m_bInitialized; // Resource is fully initialized - HRESULT Create( const char * strFilename ); - void Destroy(); - D3DResource* RegisterResource( D3DResource* pResource ) const - { - return pResource; - } + RESOURCE* m_pResourceTags; // Tags to associate names with the resources + unsigned long m_dwNumResourceTags; // Number of resource tags + public: + int m_bInitialized; // Resource is fully initialized + HRESULT Create( const char * strFilename ); + void Destroy(); - void * GetData( unsigned long dwOffset ) const - { - return &m_pSysMemData[dwOffset]; - } + D3DResource* RegisterResource( D3DResource* pResource ) const + { + return pResource; + } - D3DResource* GetResource( unsigned long dwOffset ) const - { - return (( D3DResource* )GetData( dwOffset ) ); - } + void * GetData( unsigned long dwOffset ) const + { + return &m_pSysMemData[dwOffset]; + } - D3DTexture* GetTexture( unsigned long dwOffset ) const - { - return ( D3DTexture* )GetResource( dwOffset ); - } + D3DResource* GetResource( unsigned long dwOffset ) const + { + return (( D3DResource* )GetData( dwOffset ) ); + } - D3DArrayTexture* GetArrayTexture( unsigned long dwOffset ) const - { - return ( D3DArrayTexture* )GetResource( dwOffset ); - } + D3DTexture* GetTexture( unsigned long dwOffset ) const + { + return ( D3DTexture* )GetResource( dwOffset ); + } - D3DVertexBuffer* GetVertexBuffer( unsigned long dwOffset ) const - { - return ( D3DVertexBuffer* )GetResource( dwOffset ); - } + D3DArrayTexture* GetArrayTexture( unsigned long dwOffset ) const + { + return ( D3DArrayTexture* )GetResource( dwOffset ); + } - void * GetData( const char * strName ) const; + D3DVertexBuffer* GetVertexBuffer( unsigned long dwOffset ) const + { + return ( D3DVertexBuffer* )GetResource( dwOffset ); + } - D3DResource* GetResource( const char * strName ) const - { - return ( ( D3DResource* )GetData( strName ) ); - } + void * GetData( const char * strName ) const; - D3DTexture* GetTexture( const char * strName ) const - { - return ( D3DTexture* )GetResource( strName ); - } + D3DResource* GetResource( const char * strName ) const + { + return ( ( D3DResource* )GetData( strName ) ); + } - D3DArrayTexture* GetArrayTexture( const char * strName ) const - { - return ( D3DArrayTexture* )GetResource( strName ); - } + D3DTexture* GetTexture( const char * strName ) const + { + return ( D3DTexture* )GetResource( strName ); + } - D3DVertexBuffer* GetVertexBuffer( const char * strName ) const - { - return ( D3DVertexBuffer* )GetResource( strName ); - } + D3DArrayTexture* GetArrayTexture( const char * strName ) const + { + return ( D3DArrayTexture* )GetResource( strName ); + } - PackedResource(); - ~PackedResource(); + D3DVertexBuffer* GetVertexBuffer( const char * strName ) const + { + return ( D3DVertexBuffer* )GetResource( strName ); + } + + PackedResource(); + ~PackedResource(); }; #endif diff --git a/Makefile.ps3 b/Makefile.ps3 index 7ea9033349..f42249d76b 100644 --- a/Makefile.ps3 +++ b/Makefile.ps3 @@ -68,7 +68,7 @@ endif PPU_LDLIBS = -ldbgfont $(GL_LIBS) -lretro -lcgc -lgcm_cmd -lgcm_sys_stub -lresc_stub -lm -lio_stub -lfs_stub -lsysutil_stub -lsysutil_game_stub -lsysutil_screenshot_stub -lsysutil_np_stub -lpngdec_stub -ljpgdec_stub -lsysmodule_stub -laudio_stub -lnet_stub -lnetctl_stub -lpthread -DEFINES += -DRARCH_CONSOLE -DHAVE_OPENGL -DHAVE_OPENGL_TEXREF -DHAVE_VID_CONTEXT -DHAVE_OPENGLES -DHAVE_CG -DHAVE_CG_MENU -DHAVE_FILEBROWSER -DHAVE_FBO -DHAVE_RARCH_MAIN_WRAP -DHAVE_SYSMODULES -DHAVE_SYSUTILS -DHAVE_RARCH_EXEC -DHAVE_RGL -DHAVE_LIBRETRO_MANAGEMENT -DHAVE_RSOUND -DHAVE_ZLIB -D__CELLOS_LV2__ -DHAVE_CONFIGFILE=1 -DHAVE_NETPLAY=1 -DHAVE_SOCKET_LEGACY=1 -DHAVE_GRIFFIN=1 -DPACKAGE_VERSION=\"$(RARCH_VERSION)\" -Dmain=rarch_main -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT) +DEFINES += -DRARCH_CONSOLE -DHAVE_OPENGL -DHAVE_OPENGL_TEXREF -DHAVE_HEADSET -DHAVE_VID_CONTEXT -DHAVE_OPENGLES -DHAVE_CG -DHAVE_CG_MENU -DHAVE_FILEBROWSER -DHAVE_FBO -DHAVE_RARCH_MAIN_WRAP -DHAVE_SYSMODULES -DHAVE_SYSUTILS -DHAVE_RARCH_EXEC -DHAVE_RGL -DHAVE_LIBRETRO_MANAGEMENT -DHAVE_RSOUND -DHAVE_ZLIB -D__CELLOS_LV2__ -DHAVE_CONFIGFILE=1 -DHAVE_NETPLAY=1 -DHAVE_SOCKET_LEGACY=1 -DHAVE_GRIFFIN=1 -DHAVE_MULTIMAN=1 -DPACKAGE_VERSION=\"$(RARCH_VERSION)\" -Dmain=rarch_main -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT) ifeq ($(DEBUG), 1) PPU_OPTIMIZE_LV := -O0 -g diff --git a/console/console_ext.c b/console/console_ext.c index 4e7ddff1f7..af6041b13e 100644 --- a/console/console_ext.c +++ b/console/console_ext.c @@ -27,6 +27,11 @@ #include "console_ext.h" #include "../file.h" +#ifdef HAVE_CONFIGFILE +#include "../conf/config_file.h" +#include "../conf/config_file_macros.h" +#endif + #ifdef HAVE_ZLIB #include "rzlib/zlib.h" #define WRITEBUFFERSIZE (1024 * 512) @@ -195,8 +200,8 @@ int rarch_extract_zipfile(const char *zip_path) } } - msg_queue_clear(g_extern.msg_queue); - msg_queue_push(g_extern.msg_queue, "INFO - ZIP file extracted to cache partition.", 1, 180); + if(g_console.info_msg_enable) + rarch_settings_msg(S_MSG_EXTRACTED_ZIPFILE, S_DELAY_180); return 0; } @@ -490,6 +495,14 @@ struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END] = { { "Custom", 0.0f } }; +char rotation_lut[ASPECT_RATIO_END][PATH_MAX] = +{ + "Normal", + "Vertical", + "Flipped", + "Flipped Rotated" +}; + void rarch_set_auto_viewport(unsigned width, unsigned height) { if(width == 0 || height == 0) @@ -512,100 +525,6 @@ void rarch_set_auto_viewport(unsigned width, unsigned height) aspectratio_lut[ASPECT_RATIO_AUTO].value = (int)aspect_x / (int)aspect_y; } -/*============================================================ - LIBRETRO - ============================================================ */ - -#ifdef HAVE_LIBRETRO_MANAGEMENT -bool rarch_manage_libretro_core(const char *full_path, const char *path, const char *exe_ext) -{ - g_extern.verbose = true; - bool return_code; - - bool set_libretro_path = false; - char tmp_path2[1024], tmp_pathnewfile[1024]; - RARCH_LOG("Assumed path of CORE executable: [%s]\n", full_path); - - if (path_file_exists(full_path)) - { - // if CORE executable exists, this means we have just installed - // a new libretro port and therefore we need to change it to a more - // sane name. - -#if defined(__CELLOS_LV2__) - CellFsErrno ret; -#else - int ret; -#endif - - rarch_console_name_from_id(tmp_path2, sizeof(tmp_path2)); - strlcat(tmp_path2, exe_ext, sizeof(tmp_path2)); - snprintf(tmp_pathnewfile, sizeof(tmp_pathnewfile), "%s%s", path, tmp_path2); - - if (path_file_exists(tmp_pathnewfile)) - { - // if libretro core already exists, this means we are - // upgrading the libretro core - so delete pre-existing - // file first. - - RARCH_LOG("Upgrading emulator core...\n"); -#if defined(__CELLOS_LV2__) - ret = cellFsUnlink(tmp_pathnewfile); - if (ret == CELL_FS_SUCCEEDED) -#elif defined(_XBOX) - ret = DeleteFile(tmp_pathnewfile); - if (ret != 0) -#endif - { - RARCH_LOG("Succeeded in removing pre-existing libretro core: [%s].\n", tmp_pathnewfile); - } - else - RARCH_LOG("Failed to remove pre-existing libretro core: [%s].\n", tmp_pathnewfile); - } - - //now attempt the renaming. -#if defined(__CELLOS_LV2__) - ret = cellFsRename(full_path, tmp_pathnewfile); - - if (ret != CELL_FS_SUCCEEDED) -#elif defined(_XBOX) - ret = MoveFileExA(full_path, tmp_pathnewfile, NULL); - if (ret == 0) -#endif - { - RARCH_ERR("Failed to rename CORE executable.\n"); - } - else - { - RARCH_LOG("Libsnes core [%s] renamed to: [%s].\n", full_path, tmp_pathnewfile); - set_libretro_path = true; - } - } - else - { - RARCH_LOG("CORE executable was not found, libretro core path will be loaded from config file.\n"); - } - - if (set_libretro_path) - { - // CORE executable has been renamed, libretro path will now be set to the recently - // renamed new libretro core. - strlcpy(g_settings.libretro, tmp_pathnewfile, sizeof(g_settings.libretro)); - return_code = 0; - } - else - { - // There was no CORE executable present, or the CORE executable file was not renamed. - // The libretro core path will still be loaded from the config file. - return_code = 1; - } - - g_extern.verbose = false; - - return return_code; -} -#endif - /*============================================================ RetroArch MAIN WRAP ============================================================ */ @@ -774,12 +693,12 @@ void rarch_console_rsound_stop(void) ============================================================ */ #ifdef _XBOX -wchar_t * rarch_convert_char_to_wchar(const char * str) +void rarch_convert_char_to_wchar(wchar_t *buf, const char * str, size_t size) { unsigned long dwNum = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); - wchar_t * w_str = new wchar_t[dwNum]; - MultiByteToWideChar(CP_ACP, 0, str, -1, w_str, dwNum); - return w_str; + size /= sizeof(wchar_t); + rarch_assert(size >= dwNum); + MultiByteToWideChar(CP_ACP, 0, str, -1, buf, dwNum); } #endif @@ -789,3 +708,173 @@ const char * rarch_convert_wchar_to_const_char(const wchar_t * wstr) wcstombs(str, wstr, sizeof(str)); return str; } + +/*============================================================ + CONFIG + ============================================================ */ + +#ifdef HAVE_CONFIGFILE +void rarch_config_create_default(const char * conf_name) +{ + FILE * f; + RARCH_WARN("Config file \"%s\" doesn't exist. Creating...\n", conf_name); + f = fopen(conf_name, "w"); + fclose(f); +} + +void rarch_config_load(const char * conf_name, const char * libretro_dir_path, const char * exe_ext, bool find_libretro_path) +{ + if(!path_file_exists(conf_name)) + rarch_config_create_default(conf_name); + else + { + config_file_t * conf = config_file_new(conf_name); + + // g_settings + +#ifdef HAVE_LIBRETRO_MANAGEMENT + if(find_libretro_path) + { + CONFIG_GET_STRING(libretro, "libretro_path"); + + if(!strcmp(g_settings.libretro, "")) + { + const char *first_file = rarch_manage_libretro_set_first_file(libretro_dir_path, exe_ext); + if(first_file != NULL) + strlcpy(g_settings.libretro, first_file, sizeof(g_settings.libretro)); + } + } +#endif + + CONFIG_GET_STRING(cheat_database, "cheat_database"); + CONFIG_GET_BOOL(rewind_enable, "rewind_enable"); + CONFIG_GET_STRING(video.cg_shader_path, "video_cg_shader"); +#ifdef HAVE_FBO + CONFIG_GET_STRING(video.second_pass_shader, "video_second_pass_shader"); + CONFIG_GET_FLOAT(video.fbo_scale_x, "video_fbo_scale_x"); + CONFIG_GET_FLOAT(video.fbo_scale_y, "video_fbo_scale_y"); + CONFIG_GET_BOOL(video.render_to_texture, "video_render_to_texture"); + CONFIG_GET_BOOL(video.second_pass_smooth, "video_second_pass_smooth"); +#endif +#ifdef _XBOX + CONFIG_GET_BOOL_CONSOLE(gamma_correction_enable, "gamma_correction_enable"); + CONFIG_GET_INT_CONSOLE(color_format, "color_format"); +#endif + CONFIG_GET_BOOL(video.smooth, "video_smooth"); + CONFIG_GET_BOOL(video.vsync, "video_vsync"); + CONFIG_GET_FLOAT(video.aspect_ratio, "video_aspect_ratio"); + CONFIG_GET_STRING(audio.device, "audio_device"); + + for (unsigned i = 0; i < 7; i++) + { + char cfg[64]; + snprintf(cfg, sizeof(cfg), "input_dpad_emulation_p%u", i + 1); + CONFIG_GET_INT(input.dpad_emulation[i], cfg); + } + + // g_console + +#ifdef HAVE_FBO + CONFIG_GET_BOOL_CONSOLE(fbo_enabled, "fbo_enabled"); +#endif +#ifdef __CELLOS_LV2__ + CONFIG_GET_BOOL_CONSOLE(custom_bgm_enable, "custom_bgm_enable"); +#endif + CONFIG_GET_BOOL_CONSOLE(overscan_enable, "overscan_enable"); + CONFIG_GET_BOOL_CONSOLE(screenshots_enable, "screenshots_enable"); + CONFIG_GET_BOOL_CONSOLE(throttle_enable, "throttle_enable"); + CONFIG_GET_BOOL_CONSOLE(triple_buffering_enable, "triple_buffering_enable"); + CONFIG_GET_BOOL_CONSOLE(info_msg_enable, "info_msg_enable"); + CONFIG_GET_INT_CONSOLE(aspect_ratio_index, "aspect_ratio_index"); + CONFIG_GET_INT_CONSOLE(current_resolution_id, "current_resolution_id"); + CONFIG_GET_INT_CONSOLE(viewports.custom_vp.x, "custom_viewport_x"); + CONFIG_GET_INT_CONSOLE(viewports.custom_vp.y, "custom_viewport_y"); + CONFIG_GET_INT_CONSOLE(viewports.custom_vp.width, "custom_viewport_width"); + CONFIG_GET_INT_CONSOLE(viewports.custom_vp.height, "custom_viewport_height"); + CONFIG_GET_INT_CONSOLE(screen_orientation, "screen_orientation"); + CONFIG_GET_INT_CONSOLE(sound_mode, "sound_mode"); + CONFIG_GET_STRING_CONSOLE(default_rom_startup_dir, "default_rom_startup_dir"); + CONFIG_GET_FLOAT_CONSOLE(menu_font_size, "menu_font_size"); + CONFIG_GET_FLOAT_CONSOLE(overscan_amount, "overscan_amount"); + + // g_extern + CONFIG_GET_INT_EXTERN(state_slot, "state_slot"); + CONFIG_GET_INT_EXTERN(audio_data.mute, "audio_mute"); + } +} + +void rarch_config_save(const char * conf_name) +{ + if(!path_file_exists(conf_name)) + rarch_config_create_default(conf_name); + else + { + config_file_t * conf = config_file_new(conf_name); + + if(conf == NULL) + conf = config_file_new(NULL); + + // g_settings + config_set_string(conf, "libretro_path", g_settings.libretro); +#ifdef HAVE_XML + config_set_string(conf, "cheat_database_path", g_settings.cheat_database); +#endif + config_set_bool(conf, "rewind_enable", g_settings.rewind_enable); + config_set_string(conf, "video_cg_shader", g_settings.video.cg_shader_path); + config_set_float(conf, "video_aspect_ratio", g_settings.video.aspect_ratio); +#ifdef HAVE_FBO + config_set_float(conf, "video_fbo_scale_x", g_settings.video.fbo_scale_x); + config_set_float(conf, "video_fbo_scale_y", g_settings.video.fbo_scale_y); + config_set_string(conf, "video_second_pass_shader", g_settings.video.second_pass_shader); + config_set_bool(conf, "video_render_to_texture", g_settings.video.render_to_texture); + config_set_bool(conf, "video_second_pass_smooth", g_settings.video.second_pass_smooth); +#endif + config_set_bool(conf, "video_smooth", g_settings.video.smooth); + config_set_bool(conf, "video_vsync", g_settings.video.vsync); + config_set_string(conf, "audio_device", g_settings.audio.device); + + for (unsigned i = 0; i < 7; i++) + { + char cfg[64]; + snprintf(cfg, sizeof(cfg), "input_dpad_emulation_p%u", i + 1); + config_set_int(conf, cfg, g_settings.input.dpad_emulation[i]); + } + +#ifdef RARCH_CONSOLE + config_set_bool(conf, "fbo_enabled", g_console.fbo_enabled); +#ifdef __CELLOS_LV2__ + config_set_bool(conf, "custom_bgm_enable", g_console.custom_bgm_enable); +#endif + config_set_bool(conf, "overscan_enable", g_console.overscan_enable); + config_set_bool(conf, "screenshots_enable", g_console.screenshots_enable); +#ifdef _XBOX + config_set_bool(conf, "gamma_correction_enable", g_console.gamma_correction_enable); + config_set_int(conf, "color_format", g_console.color_format); +#endif + config_set_bool(conf, "throttle_enable", g_console.throttle_enable); + config_set_bool(conf, "triple_buffering_enable", g_console.triple_buffering_enable); + config_set_bool(conf, "info_msg_enable", g_console.info_msg_enable); + config_set_int(conf, "sound_mode", g_console.sound_mode); + config_set_int(conf, "aspect_ratio_index", g_console.aspect_ratio_index); + config_set_int(conf, "current_resolution_id", g_console.current_resolution_id); + config_set_int(conf, "custom_viewport_width", g_console.viewports.custom_vp.width); + config_set_int(conf, "custom_viewport_height", g_console.viewports.custom_vp.height); + config_set_int(conf, "custom_viewport_x", g_console.viewports.custom_vp.x); + config_set_int(conf, "custom_viewport_y", g_console.viewports.custom_vp.y); + config_set_int(conf, "screen_orientation", g_console.screen_orientation); + config_set_string(conf, "default_rom_startup_dir", g_console.default_rom_startup_dir); + config_set_float(conf, "menu_font_size", g_console.menu_font_size); + config_set_float(conf, "overscan_amount", g_console.overscan_amount); +#endif + + // g_extern + config_set_int(conf, "state_slot", g_extern.state_slot); + config_set_int(conf, "audio_mute", g_extern.audio_data.mute); + + if (!config_file_write(conf, conf_name)) + RARCH_ERR("Failed to write config file to \"%s\". Check permissions.\n", conf_name); + + free(conf); + } +} +#endif diff --git a/console/console_ext.h b/console/console_ext.h index 3fabce5a31..299c8f33e8 100644 --- a/console/console_ext.h +++ b/console/console_ext.h @@ -17,10 +17,20 @@ #ifndef CONSOLE_EXT_H__ #define CONSOLE_EXT_H__ +#ifdef HAVE_LIBRETRO_MANAGEMENT +#include "libretro_mgmt.h" +#endif + +#include "console_settings.h" + #define IS_TIMER_NOT_EXPIRED(handle) (handle->frame_count < g_console.timer_expiration_frame_count) #define IS_TIMER_EXPIRED(handle) (!(IS_TIMER_NOT_EXPIRED(handle))) #define SET_TIMER_EXPIRATION(handle, value) (g_console.timer_expiration_frame_count = handle->frame_count + value) +/*============================================================ + VIDEO +============================================================ */ + enum aspect_ratio { ASPECT_RATIO_1_1 = 0, @@ -59,6 +69,24 @@ enum rotation ORIENTATION_END }; +#define LAST_ORIENTATION (ORIENTATION_END-1) + +extern char rotation_lut[ASPECT_RATIO_END][PATH_MAX]; + +/* ABGR color format defines */ + +#define WHITE 0xffffffffu +#define RED 0xff0000ffu +#define GREEN 0xff00ff00u +#define BLUE 0xffff0000u +#define YELLOW 0xff00ffffu +#define PURPLE 0xffff00ffu +#define CYAN 0xffffff00u +#define ORANGE 0xff0063ffu +#define SILVER 0xff8c848cu +#define LIGHTBLUE 0xFFFFE0E0U +#define LIGHTORANGE 0xFFE0EEFFu + struct aspect_ratio_elem { char name[64]; @@ -71,6 +99,21 @@ extern void rarch_set_auto_viewport(unsigned width, unsigned height); #include "console_ext_input.h" +/*============================================================ + SOUND +============================================================ */ + +enum +{ + SOUND_MODE_NORMAL, +#ifdef HAVE_RSOUND + SOUND_MODE_RSOUND, +#endif +#ifdef HAVE_HEADSET + SOUND_MODE_HEADSET, +#endif +}; + /*============================================================ ROM EXTENSIONS ============================================================ */ @@ -100,14 +143,35 @@ void rarch_input_set_default_keybind_names_for_emulator(void); void rarch_input_set_keybind(unsigned player, unsigned keybind_action, uint64_t default_retro_joypad_id); -#ifdef HAVE_LIBRETRO_MANAGEMENT -bool rarch_manage_libretro_core(const char *full_path, const char *path, const char *exe_ext); -#endif /*============================================================ RetroArch ============================================================ */ +enum { + MENU_ITEM_LOAD_STATE = 0, + MENU_ITEM_SAVE_STATE, + MENU_ITEM_KEEP_ASPECT_RATIO, + MENU_ITEM_OVERSCAN_AMOUNT, + MENU_ITEM_ORIENTATION, +#ifdef __CELLOS_LV2__ + MENU_ITEM_SCALE_FACTOR, +#endif + MENU_ITEM_RESIZE_MODE, + MENU_ITEM_FRAME_ADVANCE, + MENU_ITEM_SCREENSHOT_MODE, + MENU_ITEM_RESET, + MENU_ITEM_RETURN_TO_GAME, +#ifdef __CELLOS_LV2__ + MENU_ITEM_RETURN_TO_MENU, + MENU_ITEM_CHANGE_LIBRETRO, + MENU_ITEM_RETURN_TO_MULTIMAN, +#endif + MENU_ITEM_RETURN_TO_DASHBOARD +}; + +#define MENU_ITEM_LAST MENU_ITEM_RETURN_TO_DASHBOARD+1 + #ifdef HAVE_RARCH_MAIN_WRAP struct rarch_main_wrap @@ -133,10 +197,13 @@ void rarch_console_rsound_stop(void); #endif #ifdef _XBOX -wchar_t * rarch_convert_char_to_wchar(const char * str); +void rarch_convert_char_to_wchar(wchar_t *buf, const char * str, size_t size); #endif const char * rarch_convert_wchar_to_const_char(const wchar_t * wstr); +void rarch_config_create_default(const char * conf_name); +void rarch_config_load(const char * conf_name, const char * libretro_dir_path, const char * exe_ext, bool find_libretro_path); +void rarch_config_save(const char * conf_name); #endif diff --git a/console/console_settings.c b/console/console_settings.c new file mode 100644 index 0000000000..d3cd8bf268 --- /dev/null +++ b/console/console_settings.c @@ -0,0 +1,253 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2012 - Hans-Kristian Arntzen + * Copyright (C) 2011-2012 - Daniel De Matteis + * + * RetroArch 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. + * + * RetroArch 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 RetroArch. + * If not, see . + */ + +#include +#include +#include +#include + +#include "../general.h" +#include "console_settings.h" + +void rarch_settings_change(unsigned setting) +{ + switch(setting) + { + case S_ASPECT_RATIO_DECREMENT: + if(g_console.aspect_ratio_index > 0) + g_console.aspect_ratio_index--; + break; + case S_ASPECT_RATIO_INCREMENT: + if(g_console.aspect_ratio_index < LAST_ASPECT_RATIO) + g_console.aspect_ratio_index++; + break; + case S_FRAME_ADVANCE: + g_console.frame_advance_enable = true; + g_console.menu_enable = false; + g_console.mode_switch = MODE_EMULATION; + break; + case S_HW_TEXTURE_FILTER: + g_settings.video.smooth = !g_settings.video.smooth; + break; + case S_HW_TEXTURE_FILTER_2: + g_settings.video.second_pass_smooth = !g_settings.video.second_pass_smooth; + break; + case S_OVERSCAN_DECREMENT: + g_console.overscan_amount -= 0.01f; + g_console.overscan_enable = true; + if(g_console.overscan_amount == 0.0f) + g_console.overscan_enable = false; + break; + case S_OVERSCAN_INCREMENT: + g_console.overscan_amount += 0.01f; + g_console.overscan_enable = true; + if(g_console.overscan_amount == 0.0f) + g_console.overscan_enable = 0; + break; + case S_QUIT: + g_console.menu_enable = false; + g_console.ingame_menu_enable = false; + g_console.mode_switch = MODE_EXIT; + break; + case S_RETURN_TO_DASHBOARD: + g_console.menu_enable = false; + g_console.initialize_rarch_enable = false; + g_console.mode_switch = MODE_EXIT; + break; + case S_RETURN_TO_GAME: + g_console.frame_advance_enable = false; + //g_console.ingame_menu_item = 0; + g_console.menu_enable = false; + g_console.mode_switch = MODE_EMULATION; + break; + case S_RETURN_TO_LAUNCHER: + g_console.return_to_launcher = true; + g_console.menu_enable = false; + g_console.mode_switch = MODE_EXIT; + break; + case S_RETURN_TO_MENU: + g_console.menu_enable = false; + g_console.ingame_menu_item = 0; + g_console.mode_switch = MODE_MENU; + break; + case S_ROTATION_DECREMENT: + if(g_console.screen_orientation > 0) + g_console.screen_orientation--; + break; + case S_ROTATION_INCREMENT: + if(g_console.screen_orientation < LAST_ORIENTATION) + g_console.screen_orientation++; + break; + case S_START_RARCH: + g_console.menu_enable = false; + g_console.initialize_rarch_enable = 1; + g_console.mode_switch = MODE_EMULATION; + break; + case S_REWIND: + g_settings.rewind_enable = !g_settings.rewind_enable; + break; + case S_SAVESTATE_DECREMENT: + if(g_extern.state_slot != 0) + g_extern.state_slot--; + break; + case S_SAVESTATE_INCREMENT: + g_extern.state_slot++; + break; + case S_SCALE_ENABLED: + g_console.fbo_enabled = !g_console.fbo_enabled; + break; + case S_SCALE_FACTOR_DECREMENT: + g_settings.video.fbo_scale_x -= 1.0f; + g_settings.video.fbo_scale_y -= 1.0f; + break; + case S_SCALE_FACTOR_INCREMENT: + g_settings.video.fbo_scale_x += 1.0f; + g_settings.video.fbo_scale_y += 1.0f; + break; + case S_THROTTLE: + g_console.throttle_enable = !g_console.throttle_enable; + break; + case S_TRIPLE_BUFFERING: + g_console.triple_buffering_enable = !g_console.triple_buffering_enable; + break; + } +} + +void rarch_settings_default(unsigned setting) +{ + switch(setting) + { + case S_DEF_ASPECT_RATIO: + g_console.aspect_ratio_index = ASPECT_RATIO_4_3; + break; + case S_DEF_HW_TEXTURE_FILTER: + g_settings.video.smooth = 1; + break; + case S_DEF_HW_TEXTURE_FILTER_2: + g_settings.video.second_pass_smooth = 1; + break; + case S_DEF_OVERSCAN: + g_console.overscan_amount = 0.0f; + g_console.overscan_enable = false; + break; + case S_DEF_ROTATION: + g_console.screen_orientation = ORIENTATION_NORMAL; + break; + case S_DEF_THROTTLE: + g_console.throttle_enable = true; + break; + case S_DEF_TRIPLE_BUFFERING: + g_console.triple_buffering_enable = true; + break; + case S_DEF_SAVE_STATE: + g_extern.state_slot = 0; + break; + case S_DEF_SCALE_ENABLED: + g_console.fbo_enabled = true; + g_settings.video.fbo_scale_x = 2.0f; + g_settings.video.fbo_scale_y = 2.0f; + break; + case S_DEF_SCALE_FACTOR: + g_settings.video.fbo_scale_x = 2.0f; + g_settings.video.fbo_scale_y = 2.0f; + break; + } +} + +void rarch_settings_msg(unsigned setting, unsigned delay) +{ + char str[PATH_MAX]; + msg_queue_clear(g_extern.msg_queue); + + switch(setting) + { + case S_MSG_CACHE_PARTITION: + snprintf(str, sizeof(str), "INFO - All the contents of the ZIP files you have selected in the filebrowser\nare extracted to this partition."); + break; + case S_MSG_CHANGE_CONTROLS: + snprintf(str, sizeof(str), "INFO - Press LEFT/RIGHT to change the controls, and press\n[RetroPad Start] to reset a button to default values."); + break; + case S_MSG_EXTRACTED_ZIPFILE: + snprintf(str, sizeof(str), "INFO - ZIP file successfully extracted to cache partition."); + break; + case S_MSG_NOT_IMPLEMENTED: + snprintf(str, sizeof(str), "TODO - Not yet implemented."); + break; + case S_MSG_RESIZE_SCREEN: + snprintf(str, sizeof(str), "INFO - Resize the screen by moving around the two analog sticks.\nPress [RetroPad X] to reset to default values, and [RetroPad A] to go back.\nTo select the resized screen mode, set Aspect Ratio to: 'Custom'."); + break; + case S_MSG_RESTART_RARCH: + snprintf(str, sizeof(str), "INFO - You need to restart RetroArch for this change to take effect."); + break; + case S_MSG_SELECT_LIBRETRO_CORE: + snprintf(str, sizeof(str), "INFO - Select a Libretro core from the menu by pressing [RetroPad B]."); + break; + case S_MSG_SELECT_SHADER: + snprintf(str, sizeof(str), "INFO - Select a shader from the menu by pressing [RetroPad A]."); + break; + case S_MSG_SHADER_LOADING_SUCCEEDED: + snprintf(str, sizeof(str), "INFO - Shader successfully loaded."); + break; + } + + msg_queue_push(g_extern.msg_queue, str, 1, delay); +} + +#ifdef _XBOX +void rarch_settings_create_menu_item_label(wchar_t * strwbuf, unsigned setting, size_t size) +#else +void rarch_settings_create_menu_item_label(char * str, unsigned setting, size_t size) +#endif +{ +#ifdef _XBOX + char str[PATH_MAX]; + size_t SIZEOF_STR = sizeof(str); +#else + size_t SIZEOF_STR = size; +#endif + + switch (setting) + { + case S_LBL_ASPECT_RATIO: + snprintf(str, SIZEOF_STR, "Aspect Ratio: %s", aspectratio_lut[g_console.aspect_ratio_index].name); + break; + case S_LBL_SHADER: + snprintf(str, SIZEOF_STR, "Shader #1: %s", g_settings.video.cg_shader_path); + break; + case S_LBL_SHADER_2: + snprintf(str, SIZEOF_STR, "Shader #2: %s", g_settings.video.second_pass_shader); + break; + case S_LBL_RARCH_VERSION: + snprintf(str, SIZEOF_STR, "RetroArch %s", PACKAGE_VERSION); + break; + case S_LBL_SCALE_FACTOR: + snprintf(str, SIZEOF_STR, "Scale Factor: %f (X) / %f (Y)", g_settings.video.fbo_scale_x, g_settings.video.fbo_scale_y); + break; + case S_LBL_ROTATION: + snprintf(str, SIZEOF_STR, "Rotation: %s", rotation_lut[g_console.screen_orientation]); + break; + case S_LBL_LOAD_STATE_SLOT: + snprintf(str, SIZEOF_STR, "Load State #%d", g_extern.state_slot); + break; + case S_LBL_SAVE_STATE_SLOT: + snprintf(str, SIZEOF_STR, "Save State #%d", g_extern.state_slot); + break; + } + +#ifdef _XBOX + rarch_convert_char_to_wchar(strwbuf, str, size); +#endif +} diff --git a/console/console_settings.h b/console/console_settings.h new file mode 100644 index 0000000000..d2ef16c157 --- /dev/null +++ b/console/console_settings.h @@ -0,0 +1,102 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2012 - Hans-Kristian Arntzen + * Copyright (C) 2011-2012 - Daniel De Matteis + * + * RetroArch 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. + * + * RetroArch 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 RetroArch. + * If not, see . + */ + +#ifndef CONSOLE_SETTINGS_H +#define CONSOLE_SETTINGS_H + +enum +{ + S_DELAY_180 = 180, + S_DELAY_270 = 270 +}; + +enum +{ + S_ASPECT_RATIO_DECREMENT = 0, + S_ASPECT_RATIO_INCREMENT, + S_FRAME_ADVANCE, + S_HW_TEXTURE_FILTER, + S_HW_TEXTURE_FILTER_2, + S_OVERSCAN_DECREMENT, + S_OVERSCAN_INCREMENT, + S_QUIT, + S_RETURN_TO_DASHBOARD, + S_RETURN_TO_GAME, + S_RETURN_TO_LAUNCHER, + S_RETURN_TO_MENU, + S_ROTATION_DECREMENT, + S_ROTATION_INCREMENT, + S_REWIND, + S_SAVESTATE_DECREMENT, + S_SAVESTATE_INCREMENT, + S_SCALE_ENABLED, + S_SCALE_FACTOR_DECREMENT, + S_SCALE_FACTOR_INCREMENT, + S_START_RARCH, + S_THROTTLE, + S_TRIPLE_BUFFERING +}; + +enum +{ + S_DEF_ASPECT_RATIO = 0, + S_DEF_HW_TEXTURE_FILTER, + S_DEF_HW_TEXTURE_FILTER_2, + S_DEF_OVERSCAN, + S_DEF_ROTATION, + S_DEF_THROTTLE, + S_DEF_TRIPLE_BUFFERING, + S_DEF_SAVE_STATE, + S_DEF_SCALE_ENABLED, + S_DEF_SCALE_FACTOR +}; + +enum +{ + S_MSG_CACHE_PARTITION = 0, + S_MSG_CHANGE_CONTROLS, + S_MSG_EXTRACTED_ZIPFILE, + S_MSG_NOT_IMPLEMENTED, + S_MSG_RESIZE_SCREEN, + S_MSG_RESTART_RARCH, + S_MSG_SELECT_LIBRETRO_CORE, + S_MSG_SELECT_SHADER, + S_MSG_SHADER_LOADING_SUCCEEDED +}; + +enum +{ + S_LBL_ASPECT_RATIO = 0, + S_LBL_RARCH_VERSION, + S_LBL_ROTATION, + S_LBL_SHADER, + S_LBL_SHADER_2, + S_LBL_SCALE_FACTOR, + S_LBL_LOAD_STATE_SLOT, + S_LBL_SAVE_STATE_SLOT, +}; + +void rarch_settings_change(unsigned setting); +void rarch_settings_default(unsigned setting); +void rarch_settings_msg(unsigned setting, unsigned delay); + +#ifdef _XBOX +void rarch_settings_create_menu_item_label(wchar_t * strwbuf, unsigned setting, size_t size); +#else +void rarch_settings_create_menu_item_label(char * str, unsigned setting, size_t size); +#endif + +#endif diff --git a/console/fileio/file_browser.c b/console/fileio/file_browser.c index 1cafaf196c..b5fc50b23f 100644 --- a/console/fileio/file_browser.c +++ b/console/fileio/file_browser.c @@ -91,7 +91,7 @@ const char * path, const char * extensions) if(!(ffd.dwFileAttributes & FS_TYPES_DIRECTORY)) { char tmp_extensions[512]; - strncpy(tmp_extensions, extensions, sizeof(tmp_extensions)); + strlcpy(tmp_extensions, extensions, sizeof(tmp_extensions)); const char * current_extension = filebrowser_get_extension(ffd.cFileName); bool found_rom = false; @@ -158,7 +158,7 @@ const char * path, const char * extensions) if (dirent.d_type == FS_TYPES_FILE) { char tmp_extensions[512]; - strncpy(tmp_extensions, extensions, sizeof(tmp_extensions)); + strlcpy(tmp_extensions, extensions, sizeof(tmp_extensions)); const char * current_extension = filebrowser_get_extension(dirent.d_name); bool found_rom = false; diff --git a/console/fileio/file_browser.h b/console/fileio/file_browser.h index ef25ad1b92..8ebd074555 100644 --- a/console/fileio/file_browser.h +++ b/console/fileio/file_browser.h @@ -18,7 +18,6 @@ #define FILEBROWSER_H_ #define MAXJOLIET 255 -#define MAX_PATH_LENGTH 1024 #include #include diff --git a/console/griffin/griffin.c b/console/griffin/griffin.c index f2f8e4d0ce..1b3511d92e 100644 --- a/console/griffin/griffin.c +++ b/console/griffin/griffin.c @@ -22,6 +22,11 @@ CONSOLE EXTENSIONS ============================================================ */ #include "../console_ext.c" +#include "../console_settings.c" + +#ifdef HAVE_LIBRETRO_MANAGEMENT +#include "../libretro_mgmt.c" +#endif /*============================================================ COMPATIBILITY diff --git a/console/griffin/hook.h b/console/griffin/hook.h index 00748010a0..a7b6890503 100644 --- a/console/griffin/hook.h +++ b/console/griffin/hook.h @@ -40,6 +40,9 @@ #define video_set_rotation_func(rotation) gl_set_rotation(driver.video_data, rotation) #define video_set_aspect_ratio_func(aspectratio_idx) gfx_ctx_set_aspect_ratio(driver.video_data, aspectratio_idx) +#define gfx_ctx_window_has_focus() (true) +#define gfx_ctx_swap_buffers() (psglSwap()) + #define input_init_func() ps3_input_initialize() #define input_poll_func() ps3_input_poll(driver.input_data) #define input_input_state_func(snes_keybinds, port, device, index, id) \ @@ -65,6 +68,9 @@ #define video_set_rotation_func(rotation) xdk360_set_rotation(driver.video_data, rotation) #define video_set_aspect_ratio_func(aspectratio_idx) gfx_ctx_set_aspect_ratio(driver.video_data, aspectratio_idx) +#define gfx_ctx_window_has_focus() (true) +#define gfx_ctx_swap_buffers() (d3d9->d3d_render_device->Present(NULL, NULL, NULL, NULL)) + #define input_init_func() xdk360_input_initialize() #define input_poll_func() xdk360_input_poll(driver.input_data) #define input_input_state_func(snes_keybinds, port, device, index, id) \ @@ -95,5 +101,6 @@ wii_input_state(driver.input_data, snes_keybinds, port, device, index, id) #define input_key_pressed_func(key) wii_key_pressed(driver.input_data, key) #define input_free_func() wii_free_input(driver.input_data) +#define gfx_ctx_window_has_focus() (true) #endif diff --git a/console/libretro_mgmt.c b/console/libretro_mgmt.c new file mode 100644 index 0000000000..b5995b4a24 --- /dev/null +++ b/console/libretro_mgmt.c @@ -0,0 +1,136 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2012 - Hans-Kristian Arntzen + * Copyright (C) 2011-2012 - Daniel De Matteis + * + * RetroArch 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. + * + * RetroArch 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 RetroArch. + * If not, see . + */ + +#include + +#include "console_ext.h" + +const char *rarch_manage_libretro_install(const char *full_path, const char *path, const char *exe_ext) +{ + int ret; + const char *retstr = NULL; + char tmp_path2[1024], tmp_pathnewfile[1024]; + + RARCH_LOG("Assumed path of CORE executable: [%s]\n", full_path); + + if (path_file_exists(full_path)) + { + // if CORE executable exists, this means we have just installed + // a new libretro port and therefore we need to change it to a more + // sane name. + + rarch_console_name_from_id(tmp_path2, sizeof(tmp_path2)); + strlcat(tmp_path2, exe_ext, sizeof(tmp_path2)); + snprintf(tmp_pathnewfile, sizeof(tmp_pathnewfile), "%s%s", path, tmp_path2); + + if (path_file_exists(tmp_pathnewfile)) + { + // if libretro core already exists, this means we are + // upgrading the libretro core - so delete pre-existing + // file first. + + RARCH_LOG("Upgrading emulator core...\n"); +#if defined(__CELLOS_LV2__) + ret = cellFsUnlink(tmp_pathnewfile); + if (ret == CELL_FS_SUCCEEDED) +#elif defined(_XBOX) + ret = DeleteFile(tmp_pathnewfile); + if (ret != 0) +#endif + { + RARCH_LOG("Succeeded in removing pre-existing libretro core: [%s].\n", tmp_pathnewfile); + } + else + RARCH_ERR("Failed to remove pre-existing libretro core: [%s].\n", tmp_pathnewfile); + } + + //now attempt the renaming. +#if defined(__CELLOS_LV2__) + ret = cellFsRename(full_path, tmp_pathnewfile); + + if (ret != CELL_FS_SUCCEEDED) +#elif defined(_XBOX) + ret = MoveFileExA(full_path, tmp_pathnewfile, NULL); + if (ret == 0) +#endif + { + RARCH_ERR("Failed to rename CORE executable.\n"); + } + else + { + RARCH_LOG("Libsnes core [%s] renamed to: [%s].\n", full_path, tmp_pathnewfile); + retstr = tmp_pathnewfile; + goto done; + } + } + + RARCH_WARN("CORE executable was not found, or some other errors occurred. Will attempt to load libretro core path from config file.\n"); +done: + return retstr; +} + +const char *rarch_manage_libretro_set_first_file(const char *libretro_path, const char * exe_ext) +{ + //We need to set libretro to the first entry in the cores + //directory so that it will be saved to the config file + + char ** dir_list = dir_list_new(libretro_path, exe_ext); + + const char * retstr = NULL; + const char * first_exe; + + if (!dir_list) + { + RARCH_ERR("Couldn't read directory.\n"); + goto error; + } + + first_exe = dir_list[0]; + + if(first_exe) + { +#ifdef _XBOX + char fname_tmp[PATH_MAX]; + fill_pathname_base(fname_tmp, first_exe, sizeof(fname_tmp)); + + if(strcmp(fname_tmp, "RetroArch-Salamander.xex") == 0) + { + RARCH_WARN("First entry is RetroArch Salamander itself, increment entry by one and check if it exists.\n"); + first_exe = dir_list[1]; + fill_pathname_base(fname_tmp, first_exe, sizeof(fname_tmp)); + + if(!first_exe) + { + RARCH_ERR("Unlikely error happened - no second entry - no choice but to set it to RetroArch Salamander\n"); + first_exe = dir_list[0]; + fill_pathname_base(fname_tmp, first_exe, sizeof(fname_tmp)); + } + } + + retstr = fname_tmp; +#else + retstr = first_exe; +#endif + RARCH_LOG("Set first entry in libretro core dir to libretro path: [%s].\n", retstr); + goto end; + } + +error: + RARCH_ERR("Failed to set first entry to libretro path.\n"); +end: + dir_list_free(dir_list); + return retstr; +} diff --git a/360/shared.h b/console/libretro_mgmt.h similarity index 64% rename from 360/shared.h rename to console/libretro_mgmt.h index c6e0a82589..b32db42850 100644 --- a/360/shared.h +++ b/console/libretro_mgmt.h @@ -14,25 +14,20 @@ * If not, see . */ -#ifndef _360_SHARED_H -#define _360_SHARED_H +#ifndef LIBRETRO_MGMT_H__ +#define LIBRETRO_MGMT_H__ -#define MAX_PATH_LENGTH 1024 +#include "../boolean.h" -enum { - MENU_ITEM_LOAD_STATE = 0, - MENU_ITEM_SAVE_STATE, - MENU_ITEM_KEEP_ASPECT_RATIO, - MENU_ITEM_OVERSCAN_AMOUNT, - MENU_ITEM_ORIENTATION, - MENU_ITEM_RESIZE_MODE, - MENU_ITEM_FRAME_ADVANCE, - MENU_ITEM_SCREENSHOT_MODE, - MENU_ITEM_RESET, - MENU_ITEM_RETURN_TO_GAME, - MENU_ITEM_RETURN_TO_DASHBOARD +enum +{ + EXTERN_LAUNCHER_SALAMANDER, +#ifdef HAVE_MULTIMAN + EXTERN_LAUNCHER_MULTIMAN +#endif }; -#define MENU_ITEM_LAST MENU_ITEM_RETURN_TO_DASHBOARD+1 +const char *rarch_manage_libretro_install(const char *full_path, const char *path, const char *exe_ext); +const char *rarch_manage_libretro_set_first_file(const char *libretro_path, const char * exe_ext); #endif diff --git a/console/librsound/librsound.c b/console/librsound/librsound.c index 4b18d46a8d..c7366b054f 100644 --- a/console/librsound/librsound.c +++ b/console/librsound/librsound.c @@ -1415,7 +1415,7 @@ int rsd_set_param(rsound_t *rd, enum rsd_settings option, void* param) break; case RSD_IDENTITY: - strncpy(rd->identity, param, sizeof(rd->identity)); + strlcpy(rd->identity, param, sizeof(rd->identity)); rd->identity[sizeof(rd->identity)-1] = '\0'; break; diff --git a/console/salamander/main.c b/console/salamander/main.c index f9b84205fc..429ea54178 100644 --- a/console/salamander/main.c +++ b/console/salamander/main.c @@ -44,8 +44,6 @@ #define PATH_MAX 512 #endif -#define MAX_PATH_LENGTH 1024 - #ifdef HAVE_LOGGER #include "logger.h" #define RARCH_LOG(...) logger_send("RetroArch Salamander: " __VA_ARGS__); @@ -72,16 +70,16 @@ #if defined(__CELLOS_LV2__) static uint8_t np_pool[NP_POOL_SIZE]; -char contentInfoPath[MAX_PATH_LENGTH]; -char usrDirPath[MAX_PATH_LENGTH]; +char contentInfoPath[PATH_MAX]; +char usrDirPath[PATH_MAX]; SYS_PROCESS_PARAM(1001, 0x100000) #elif defined(_XBOX) DWORD volume_device_type; #endif -char LIBRETRO_DIR_PATH[MAX_PATH_LENGTH]; -char SYS_CONFIG_FILE[MAX_PATH_LENGTH]; -char libretro_path[MAX_PATH_LENGTH]; +char LIBRETRO_DIR_PATH[PATH_MAX]; +char SYS_CONFIG_FILE[PATH_MAX]; +char libretro_path[PATH_MAX]; static void find_and_set_first_file(void) { @@ -107,7 +105,7 @@ static void find_and_set_first_file(void) #ifdef _XBOX //Check if it's RetroArch Salamander itself - if so, first_executable needs to //be overridden - char fname_tmp[MAX_PATH_LENGTH]; + char fname_tmp[PATH_MAX]; fill_pathname_base(fname_tmp, first_executable, sizeof(fname_tmp)); @@ -140,7 +138,7 @@ static void find_and_set_first_file(void) static void init_settings(void) { - char tmp_str[MAX_PATH_LENGTH]; + char tmp_str[PATH_MAX]; bool config_file_exists; if(!path_file_exists(SYS_CONFIG_FILE)) diff --git a/general.h b/general.h index ae37043b7a..40c75fe97a 100644 --- a/general.h +++ b/general.h @@ -207,8 +207,12 @@ struct console_settings bool default_savestate_dir_enable; bool fbo_enabled; bool frame_advance_enable; - bool gamma_correction_enable; +#ifdef _XBOX + bool menus_hd_enable; +#endif bool initialize_rarch_enable; + bool info_msg_enable; + bool gamma_correction_enable; bool ingame_menu_enable; bool menu_enable; bool overscan_enable; @@ -477,6 +481,8 @@ int rarch_main_init(int argc, char *argv[]); bool rarch_main_iterate(void); void rarch_main_deinit(void); void rarch_render_cached_frame(void); +void rarch_init_msg_queue(void); +void rarch_deinit_msg_queue(void); void rarch_load_state(void); void rarch_save_state(void); diff --git a/gfx/context/ps3_ctx.c b/gfx/context/ps3_ctx.c index 0822cbc4ee..4d137d574f 100644 --- a/gfx/context/ps3_ctx.c +++ b/gfx/context/ps3_ctx.c @@ -95,17 +95,20 @@ void gfx_ctx_check_window(bool *quit, *resize = true; } +#ifndef HAVE_GRIFFIN bool gfx_ctx_window_has_focus(void) { return true; } -void gfx_ctx_set_resize(unsigned width, unsigned height) { } - void gfx_ctx_swap_buffers(void) { psglSwap(); } +#endif + +void gfx_ctx_set_resize(unsigned width, unsigned height) { } + bool gfx_ctx_menu_init(void) { @@ -324,7 +327,7 @@ void ps3_previous_resolution (void) } } -int ps3_check_resolution(uint32_t resolution_id) +int gfx_ctx_check_resolution(unsigned resolution_id) { return cellVideoOutGetResolutionAvailability(CELL_VIDEO_OUT_PRIMARY, resolution_id, CELL_VIDEO_OUT_ASPECT_AUTO, 0); } @@ -408,4 +411,3 @@ void gfx_ctx_set_overscan(void) gl->should_resize = true; } - diff --git a/gfx/context/xdk360_ctx.c b/gfx/context/xdk360_ctx.c index 31d7453d40..4f09da154f 100644 --- a/gfx/context/xdk360_ctx.c +++ b/gfx/context/xdk360_ctx.c @@ -51,19 +51,21 @@ void gfx_ctx_check_window(bool *quit, *resize = true; } -bool gfx_ctx_window_has_focus(void) -{ - return true; -} - void gfx_ctx_set_resize(unsigned width, unsigned height) { } +#ifndef HAVE_GRIFFIN void gfx_ctx_swap_buffers(void) { xdk360_video_t *d3d9 = (xdk360_video_t*)driver.video_data; d3d9->d3d_render_device->Present(NULL, NULL, NULL, NULL); } +bool gfx_ctx_window_has_focus(void) +{ + return true; +} +#endif + bool gfx_ctx_menu_init(void) { return true; @@ -133,3 +135,7 @@ void gfx_ctx_set_overscan(void) d3d9->should_resize = true; } +int gfx_ctx_check_resolution(unsigned resolution_id) +{ + return 0; +} diff --git a/gfx/fonts/ps3_libdbgfont.c b/gfx/fonts/ps3_libdbgfont.c index 3279d9fc0b..9ed58d8f34 100644 --- a/gfx/fonts/ps3_libdbgfont.c +++ b/gfx/fonts/ps3_libdbgfont.c @@ -46,4 +46,3 @@ void gl_render_msg_post(gl_t *gl) { cellDbgFontDraw(); } - diff --git a/gfx/gfx_context.h b/gfx/gfx_context.h index cd1ba4cb52..56961e97e3 100644 --- a/gfx/gfx_context.h +++ b/gfx/gfx_context.h @@ -1,8 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2012 - Hans-Kristian Arntzen * - - * * RetroArch 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. @@ -51,8 +49,6 @@ void gfx_ctx_destroy(void); void gfx_ctx_get_video_size(unsigned *width, unsigned *height); void gfx_ctx_update_window_title(bool reset); -void gfx_ctx_swap_buffers(void); - bool gfx_ctx_key_pressed(int key); void gfx_ctx_check_window(bool *quit, @@ -64,8 +60,12 @@ void gfx_ctx_set_resize(unsigned width, unsigned height); bool gfx_ctx_get_wm_info(SDL_SysWMinfo *info); #endif +#ifndef HAVE_GRIFFIN bool gfx_ctx_window_has_focus(void); +void gfx_ctx_swap_buffers(void); +#endif + void gfx_ctx_input_driver(const input_driver_t **input, void **input_data); #ifdef HAVE_CG_MENU @@ -75,6 +75,7 @@ bool gfx_ctx_menu_init(void); #ifdef RARCH_CONSOLE void gfx_ctx_set_filtering(unsigned index, bool set_smooth); void gfx_ctx_get_available_resolutions(void); +int gfx_ctx_check_resolution(unsigned resolution_id); #endif #if defined(HAVE_OPENGL) || defined(HAVE_D3D9) diff --git a/gfx/gl.c b/gfx/gl.c index 37749d4669..1b3352bb43 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -542,20 +542,6 @@ static inline void set_texture_coords(GLfloat *coords, GLfloat xamt, GLfloat yam coords[7] = yamt; } -static void check_window(gl_t *gl) -{ - bool quit, resize; - - gfx_ctx_check_window(&quit, - &resize, &gl->win_width, &gl->win_height, - gl->frame_count); - - if (quit) - gl->quitting = true; - else if (resize) - gl->should_resize = true; -} - #ifdef HAVE_FBO static void gl_compute_fbo_geometry(gl_t *gl, unsigned width, unsigned height, unsigned vp_width, unsigned vp_height) @@ -612,7 +598,7 @@ static void gl_compute_fbo_geometry(gl_t *gl, unsigned width, unsigned height, } } -static void gl_start_frame_fbo(gl_t *gl) +static inline void gl_start_frame_fbo(gl_t *gl) { glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]); pglBindFramebuffer(GL_FRAMEBUFFER, gl->fbo[0]); @@ -794,7 +780,7 @@ static void gl_update_input_size(gl_t *gl, unsigned width, unsigned height, unsi } #ifdef __CELLOS_LV2__ -static void gl_copy_frame(gl_t *gl, const void *frame, unsigned width, unsigned height, unsigned pitch) +static inline void gl_copy_frame(gl_t *gl, const void *frame, unsigned width, unsigned height, unsigned pitch) { if (!gl->fbo_inited) gl_set_viewport(gl, gl->win_width, gl->win_height, false, true); @@ -838,7 +824,7 @@ static void gl_init_textures(gl_t *gl) glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]); } #else -static void gl_copy_frame(gl_t *gl, const void *frame, unsigned width, unsigned height, unsigned pitch) +static inline void gl_copy_frame(gl_t *gl, const void *frame, unsigned width, unsigned height, unsigned pitch) { glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch / gl->base_size); glTexSubImage2D(GL_TEXTURE_2D, @@ -867,7 +853,7 @@ static void gl_init_textures(gl_t *gl) } #endif -static void gl_next_texture_index(gl_t *gl, const struct gl_tex_info *tex_info) +static inline void gl_next_texture_index(gl_t *gl, const struct gl_tex_info *tex_info) { memmove(gl->prev_info + 1, gl->prev_info, sizeof(*tex_info) * (TEXTURES - 1)); memcpy(&gl->prev_info[0], tex_info, sizeof(*tex_info)); @@ -958,7 +944,9 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei gl_render_msg_post(gl); } +#ifndef RARCH_CONSOLE gfx_ctx_update_window_title(false); +#endif #ifdef RARCH_CONSOLE if (!gl->block_swap) @@ -1189,7 +1177,17 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo static bool gl_alive(void *data) { gl_t *gl = (gl_t*)data; - check_window(gl); + bool quit, resize; + + gfx_ctx_check_window(&quit, + &resize, &gl->win_width, &gl->win_height, + gl->frame_count); + + if (quit) + gl->quitting = true; + else if (resize) + gl->should_resize = true; + return !gl->quitting; } @@ -1267,14 +1265,38 @@ static void gl_stop(void) static void gl_restart(void) { +#ifdef HAVE_CG_MENU + bool should_menu_render; +#endif +#ifdef RARCH_CONSOLE + bool should_block_swap; +#endif gl_t *gl = driver.video_data; if (!gl) return; +#ifdef RARCH_CONSOLE + should_block_swap = gl->block_swap; +#endif +#ifdef HAVE_CG_MENU + should_menu_render = gl->menu_render; +#endif + gl_stop(); gl_cg_invalidate_context(); gl_start(); + +#ifdef HAVE_CG_MENU + gl->menu_render = should_menu_render; +#endif + + gl->frame_count = 0; + +#ifdef RARCH_CONSOLE + gl->block_swap = should_block_swap; + SET_TIMER_EXPIRATION(gl, 30); +#endif } #endif diff --git a/gfx/gl_font.h b/gfx/gl_font.h index cc74950e93..b355b91642 100644 --- a/gfx/gl_font.h +++ b/gfx/gl_font.h @@ -22,6 +22,7 @@ void gl_init_font(gl_t *gl, const char *font_path, unsigned font_size); void gl_deinit_font(gl_t *gl); void gl_render_msg(gl_t *gl, const char *msg); + void gl_render_msg_post(gl_t *gl); #endif diff --git a/gfx/shader_cg.c b/gfx/shader_cg.c index 17837fee71..73a2a82a03 100644 --- a/gfx/shader_cg.c +++ b/gfx/shader_cg.c @@ -805,30 +805,36 @@ static bool load_shader_params(unsigned i, config_file_t *conf) scale->abs_x = geom->base_width; scale->abs_y = geom->base_height; - if (strcmp(scale_type_x, "source") == 0) - scale->type_x = RARCH_SCALE_INPUT; - else if (strcmp(scale_type_x, "viewport") == 0) - scale->type_x = RARCH_SCALE_VIEWPORT; - else if (strcmp(scale_type_x, "absolute") == 0) - scale->type_x = RARCH_SCALE_ABSOLUTE; - else + if (scale_type_x) { - RARCH_ERR("Invalid attribute.\n"); - ret = false; - goto end; + if (strcmp(scale_type_x, "source") == 0) + scale->type_x = RARCH_SCALE_INPUT; + else if (strcmp(scale_type_x, "viewport") == 0) + scale->type_x = RARCH_SCALE_VIEWPORT; + else if (strcmp(scale_type_x, "absolute") == 0) + scale->type_x = RARCH_SCALE_ABSOLUTE; + else + { + RARCH_ERR("Invalid attribute.\n"); + ret = false; + goto end; + } } - if (strcmp(scale_type_y, "source") == 0) - scale->type_y = RARCH_SCALE_INPUT; - else if (strcmp(scale_type_y, "viewport") == 0) - scale->type_y = RARCH_SCALE_VIEWPORT; - else if (strcmp(scale_type_y, "absolute") == 0) - scale->type_y = RARCH_SCALE_ABSOLUTE; - else + if (scale_type_y) { - RARCH_ERR("Invalid attribute.\n"); - ret = false; - goto end; + if (strcmp(scale_type_y, "source") == 0) + scale->type_y = RARCH_SCALE_INPUT; + else if (strcmp(scale_type_y, "viewport") == 0) + scale->type_y = RARCH_SCALE_VIEWPORT; + else if (strcmp(scale_type_y, "absolute") == 0) + scale->type_y = RARCH_SCALE_ABSOLUTE; + else + { + RARCH_ERR("Invalid attribute.\n"); + ret = false; + goto end; + } } if (scale->type_x == RARCH_SCALE_ABSOLUTE) diff --git a/gfx/shader_hlsl.c b/gfx/shader_hlsl.c index c931fe5afb..85f0ff662d 100644 --- a/gfx/shader_hlsl.c +++ b/gfx/shader_hlsl.c @@ -131,16 +131,12 @@ void hlsl_set_params(unsigned width, unsigned height, static bool load_program(unsigned index, const char *prog, bool path_is_file) { - bool ret, ret_fp, ret_vp; + HRESULT ret, ret_fp, ret_vp; ID3DXBuffer *listing_f = NULL; ID3DXBuffer *listing_v = NULL; ID3DXBuffer *code_f = NULL; ID3DXBuffer *code_v = NULL; - ret = true; - ret_fp = false; - ret_vp = false; - if (path_is_file) { ret_fp = D3DXCompileShaderFromFile(prog, NULL, NULL, @@ -157,7 +153,7 @@ static bool load_program(unsigned index, const char *prog, bool path_is_file) "main_vertex", "vs_3_0", 0, &code_v, &listing_v, &prg[index].v_ctable ); } - if (FAILED(ret_fp) || FAILED(ret_vp) || listing_v || listing_f) + if (ret_fp < 0 || ret_vp < 0 || listing_v || listing_f) { RARCH_ERR("HLSL error:\n"); if(listing_f) diff --git a/ps3/main.c b/ps3/main.c index c674c262f8..9a5fb096d6 100644 --- a/ps3/main.c +++ b/ps3/main.c @@ -52,8 +52,6 @@ #include "menu.h" -#define MAX_PATH_LENGTH 1024 - #define EMULATOR_CONTENT_DIR "SSNE10000" #define EMULATOR_CORE_DIR "cores" @@ -61,21 +59,23 @@ #define NP_POOL_SIZE (128*1024) static uint8_t np_pool[NP_POOL_SIZE]; -char contentInfoPath[MAX_PATH_LENGTH]; -char usrDirPath[MAX_PATH_LENGTH]; -char DEFAULT_PRESET_FILE[MAX_PATH_LENGTH]; -char DEFAULT_BORDER_FILE[MAX_PATH_LENGTH]; -char DEFAULT_MENU_BORDER_FILE[MAX_PATH_LENGTH]; -char PRESETS_DIR_PATH[MAX_PATH_LENGTH]; -char INPUT_PRESETS_DIR_PATH[MAX_PATH_LENGTH]; -char BORDERS_DIR_PATH[MAX_PATH_LENGTH]; -char SHADERS_DIR_PATH[MAX_PATH_LENGTH]; -char LIBRETRO_DIR_PATH[MAX_PATH_LENGTH]; -char DEFAULT_SHADER_FILE[MAX_PATH_LENGTH]; -char DEFAULT_MENU_SHADER_FILE[MAX_PATH_LENGTH]; -char SYS_CONFIG_FILE[MAX_PATH_LENGTH]; -char EMULATOR_CORE_SELF[MAX_PATH_LENGTH]; -char MULTIMAN_EXECUTABLE[MAX_PATH_LENGTH]; +char contentInfoPath[PATH_MAX]; +char usrDirPath[PATH_MAX]; +char DEFAULT_PRESET_FILE[PATH_MAX]; +char DEFAULT_BORDER_FILE[PATH_MAX]; +char DEFAULT_MENU_BORDER_FILE[PATH_MAX]; +char PRESETS_DIR_PATH[PATH_MAX]; +char INPUT_PRESETS_DIR_PATH[PATH_MAX]; +char BORDERS_DIR_PATH[PATH_MAX]; +char SHADERS_DIR_PATH[PATH_MAX]; +char LIBRETRO_DIR_PATH[PATH_MAX]; +char DEFAULT_SHADER_FILE[PATH_MAX]; +char DEFAULT_MENU_SHADER_FILE[PATH_MAX]; +char SYS_CONFIG_FILE[PATH_MAX]; +char EMULATOR_CORE_SELF[PATH_MAX]; +#ifdef HAVE_MULTIMAN +char MULTIMAN_EXECUTABLE[PATH_MAX]; +#endif int rarch_main(int argc, char *argv[]); @@ -91,6 +91,7 @@ static void set_default_settings(void) strlcpy(g_settings.video.cg_shader_path, DEFAULT_SHADER_FILE, sizeof(g_settings.video.cg_shader_path)); g_settings.video.fbo_scale_x = 2.0f; g_settings.video.fbo_scale_y = 2.0f; + g_settings.video.render_to_texture = true; strlcpy(g_settings.video.second_pass_shader, DEFAULT_SHADER_FILE, sizeof(g_settings.video.second_pass_shader)); g_settings.video.second_pass_smooth = true; g_settings.video.smooth = true; @@ -147,6 +148,7 @@ static void set_default_settings(void) g_console.viewports.custom_vp.x = 0; g_console.viewports.custom_vp.y = 0; g_console.custom_bgm_enable = true; + g_console.info_msg_enable = true; // g_extern g_extern.state_slot = 0; @@ -154,167 +156,6 @@ static void set_default_settings(void) g_extern.verbose = true; } -static void init_settings(bool load_libretro_path) -{ - if(!path_file_exists(SYS_CONFIG_FILE)) - { - RARCH_ERR("Config file \"%s\" doesn't exist. Creating...\n", SYS_CONFIG_FILE); - FILE * f; - f = fopen(SYS_CONFIG_FILE, "w"); - fclose(f); - } - else - { - config_file_t * conf = config_file_new(SYS_CONFIG_FILE); - - // g_settings - - if(load_libretro_path) - { - CONFIG_GET_STRING(libretro, "libretro_path"); - - if(!strcmp(g_settings.libretro, "")) - { - //We need to set libretro to the first entry in the cores - //directory so that it will be saved to the config file - char ** dir_list = dir_list_new(LIBRETRO_DIR_PATH, ".SELF"); - - if (!dir_list) - { - RARCH_ERR("Couldn't read %s directory.\n", EMULATOR_CORE_DIR); - return; - } - - const char * first_self = dir_list[0]; - - if(first_self) - { - RARCH_LOG("Set first entry in libretro %s dir: [%s] to libretro path.\n", EMULATOR_CORE_DIR, first_self); - strlcpy(g_settings.libretro, first_self, sizeof(g_settings.libretro)); - } - else - { - RARCH_ERR("Failed to set first entry in libretro %s dir to libretro path.\n", EMULATOR_CORE_DIR); - } - - dir_list_free(dir_list); - } - } - - CONFIG_GET_STRING(cheat_database, "cheat_database"); - CONFIG_GET_BOOL(rewind_enable, "rewind_enable"); - CONFIG_GET_STRING(video.cg_shader_path, "video_cg_shader"); - CONFIG_GET_STRING(video.second_pass_shader, "video_second_pass_shader"); - CONFIG_GET_FLOAT(video.fbo_scale_x, "video_fbo_scale_x"); - CONFIG_GET_FLOAT(video.fbo_scale_y, "video_fbo_scale_y"); - CONFIG_GET_BOOL(video.render_to_texture, "video_render_to_texture"); - CONFIG_GET_BOOL(video.second_pass_smooth, "video_second_pass_smooth"); - CONFIG_GET_BOOL(video.smooth, "video_smooth"); - CONFIG_GET_BOOL(video.vsync, "video_vsync"); - CONFIG_GET_FLOAT(video.aspect_ratio, "video_aspect_ratio"); - CONFIG_GET_STRING(audio.device, "audio_device"); - - for (unsigned i = 0; i < 7; i++) - { - char cfg[64]; - snprintf(cfg, sizeof(cfg), "input_dpad_emulation_p%u", i + 1); - CONFIG_GET_INT(input.dpad_emulation[i], cfg); - } - - // g_console - - CONFIG_GET_BOOL_CONSOLE(fbo_enabled, "fbo_enabled"); - CONFIG_GET_BOOL_CONSOLE(custom_bgm_enable, "custom_bgm_enable"); - CONFIG_GET_BOOL_CONSOLE(overscan_enable, "overscan_enable"); - CONFIG_GET_BOOL_CONSOLE(screenshots_enable, "screenshots_enable"); - CONFIG_GET_BOOL_CONSOLE(throttle_enable, "throttle_enable"); - CONFIG_GET_BOOL_CONSOLE(triple_buffering_enable, "triple_buffering_enable"); - CONFIG_GET_INT_CONSOLE(aspect_ratio_index, "aspect_ratio_index"); - CONFIG_GET_INT_CONSOLE(current_resolution_id, "current_resolution_id"); - CONFIG_GET_INT_CONSOLE(viewports.custom_vp.x, "custom_viewport_x"); - CONFIG_GET_INT_CONSOLE(viewports.custom_vp.y, "custom_viewport_y"); - CONFIG_GET_INT_CONSOLE(viewports.custom_vp.width, "custom_viewport_width"); - CONFIG_GET_INT_CONSOLE(viewports.custom_vp.height, "custom_viewport_height"); - CONFIG_GET_INT_CONSOLE(screen_orientation, "screen_orientation"); - CONFIG_GET_INT_CONSOLE(sound_mode, "sound_mode"); - CONFIG_GET_STRING_CONSOLE(default_rom_startup_dir, "default_rom_startup_dir"); - CONFIG_GET_FLOAT_CONSOLE(menu_font_size, "menu_font_size"); - CONFIG_GET_FLOAT_CONSOLE(overscan_amount, "overscan_amount"); - - // g_extern - CONFIG_GET_INT_EXTERN(state_slot, "state_slot"); - CONFIG_GET_INT_EXTERN(audio_data.mute, "audio_mute"); - } -} - -static void save_settings(void) -{ - if(!path_file_exists(SYS_CONFIG_FILE)) - { - RARCH_ERR("Config file \"%s\" doesn't exist. Creating...\n", SYS_CONFIG_FILE); - FILE * f; - f = fopen(SYS_CONFIG_FILE, "w"); - fclose(f); - } - else - { - config_file_t * conf = config_file_new(SYS_CONFIG_FILE); - - if(conf == NULL) - conf = config_file_new(NULL); - - // g_settings - config_set_string(conf, "libretro_path", g_settings.libretro); - config_set_string(conf, "cheat_database_path", g_settings.cheat_database); - config_set_bool(conf, "rewind_enable", g_settings.rewind_enable); - config_set_string(conf, "video_cg_shader", g_settings.video.cg_shader_path); - config_set_string(conf, "video_second_pass_shader", g_settings.video.second_pass_shader); - config_set_float(conf, "video_aspect_ratio", g_settings.video.aspect_ratio); - config_set_float(conf, "video_fbo_scale_x", g_settings.video.fbo_scale_x); - config_set_float(conf, "video_fbo_scale_y", g_settings.video.fbo_scale_y); - config_set_bool(conf, "video_render_to_texture", g_settings.video.render_to_texture); - config_set_bool(conf, "video_second_pass_smooth", g_settings.video.second_pass_smooth); - config_set_bool(conf, "video_smooth", g_settings.video.smooth); - config_set_bool(conf, "video_vsync", g_settings.video.vsync); - config_set_string(conf, "audio_device", g_settings.audio.device); - - for (unsigned i = 0; i < 7; i++) - { - char cfg[64]; - snprintf(cfg, sizeof(cfg), "input_dpad_emulation_p%u", i + 1); - config_set_int(conf, cfg, g_settings.input.dpad_emulation[i]); - } - - // g_console - config_set_bool(conf, "fbo_enabled", g_console.fbo_enabled); - config_set_bool(conf, "custom_bgm_enable", g_console.custom_bgm_enable); - config_set_bool(conf, "overscan_enable", g_console.overscan_enable); - config_set_bool(conf, "screenshots_enable", g_console.screenshots_enable); - config_set_bool(conf, "throttle_enable", g_console.throttle_enable); - config_set_bool(conf, "triple_buffering_enable", g_console.triple_buffering_enable); - config_set_int(conf, "sound_mode", g_console.sound_mode); - config_set_int(conf, "aspect_ratio_index", g_console.aspect_ratio_index); - config_set_int(conf, "current_resolution_id", g_console.current_resolution_id); - config_set_int(conf, "custom_viewport_width", g_console.viewports.custom_vp.width); - config_set_int(conf, "custom_viewport_height", g_console.viewports.custom_vp.height); - config_set_int(conf, "custom_viewport_x", g_console.viewports.custom_vp.x); - config_set_int(conf, "custom_viewport_y", g_console.viewports.custom_vp.y); - config_set_int(conf, "screen_orientation", g_console.screen_orientation); - config_set_string(conf, "default_rom_startup_dir", g_console.default_rom_startup_dir); - config_set_float(conf, "menu_font_size", g_console.menu_font_size); - config_set_float(conf, "overscan_amount", g_console.overscan_amount); - - // g_extern - config_set_int(conf, "state_slot", g_extern.state_slot); - config_set_int(conf, "audio_mute", g_extern.audio_data.mute); - - if (!config_file_write(conf, SYS_CONFIG_FILE)) - RARCH_ERR("Failed to write config file to \"%s\". Check permissions.\n", SYS_CONFIG_FILE); - - free(conf); - } -} - #ifdef HAVE_SYSUTILS static void callback_sysutil_exit(uint64_t status, uint64_t param, void *userdata) { @@ -325,10 +166,8 @@ static void callback_sysutil_exit(uint64_t status, uint64_t param, void *userdat switch (status) { case CELL_SYSUTIL_REQUEST_EXITGAME: - g_console.menu_enable = false; gl->quitting = true; - g_console.ingame_menu_enable = false; - g_console.mode_switch = MODE_EXIT; + rarch_settings_change(S_QUIT); break; case CELL_SYSUTIL_OSKDIALOG_FINISHED: oskutil_close(&g_console.oskutil_handle); @@ -352,7 +191,7 @@ static void get_environment_settings(int argc, char *argv[]) char dirName[CELL_GAME_DIRNAME_SIZE]; CellSysCacheParam param; memset(¶m, 0x00, sizeof(CellSysCacheParam)); - strncpy(param.cacheId,CACHE_ID, sizeof(CellSysCacheParam)); + strlcpy(param.cacheId,CACHE_ID, sizeof(CellSysCacheParam)); ret = cellSysCacheMount(¶m); if(ret != CELL_SYSCACHE_RET_OK_CLEARED) @@ -360,15 +199,16 @@ static void get_environment_settings(int argc, char *argv[]) RARCH_ERR("System cache partition could not be mounted, it might be already mounted.\n"); } +#ifdef HAVE_MULTIMAN if(argc > 1) { /* launched from external launcher */ - strncpy(MULTIMAN_EXECUTABLE, argv[2], sizeof(MULTIMAN_EXECUTABLE)); + strlcpy(MULTIMAN_EXECUTABLE, argv[2], sizeof(MULTIMAN_EXECUTABLE)); } else { /* not launched from external launcher, set default path */ - strncpy(MULTIMAN_EXECUTABLE, "/dev_hdd0/game/BLES80608/USRDIR/RELOAD.SELF", + strlcpy(MULTIMAN_EXECUTABLE, "/dev_hdd0/game/BLES80608/USRDIR/RELOAD.SELF", sizeof(MULTIMAN_EXECUTABLE)); } @@ -378,6 +218,7 @@ static void get_environment_settings(int argc, char *argv[]) RARCH_LOG("Started from multiMAN, auto-game start enabled.\n"); } else +#endif { g_console.external_launcher_support = EXTERN_LAUNCHER_SALAMANDER; RARCH_WARN("Not started from multiMAN, auto-game start disabled.\n"); @@ -411,11 +252,13 @@ static void get_environment_settings(int argc, char *argv[]) ret = cellGameContentPermit(contentInfoPath, usrDirPath); +#ifdef HAVE_MULTIMAN if(g_console.external_launcher_support == EXTERN_LAUNCHER_MULTIMAN) { snprintf(contentInfoPath, sizeof(contentInfoPath), "/dev_hdd0/game/%s", EMULATOR_CONTENT_DIR); snprintf(usrDirPath, sizeof(usrDirPath), "/dev_hdd0/game/%s/USRDIR", EMULATOR_CONTENT_DIR); } +#endif if(ret < 0) { @@ -476,15 +319,25 @@ int main(int argc, char *argv[]) config_set_defaults(); - rarch_assert(g_extern.msg_queue = msg_queue_new(8)); - char full_path[1024], tmp_path[1024]; snprintf(full_path, sizeof(full_path), "%s/%s/CORE.SELF", usrDirPath, EMULATOR_CORE_DIR); snprintf(tmp_path, sizeof(tmp_path), "%s/%s/", usrDirPath, EMULATOR_CORE_DIR); - bool load_libretro_path = rarch_manage_libretro_core(full_path, tmp_path, ".SELF"); + + g_extern.verbose = true; + + const char *libretro_core_installed = rarch_manage_libretro_install(full_path, tmp_path, ".SELF"); + + g_extern.verbose = false; + + bool find_libretro_file = false; + + if(libretro_core_installed != NULL) + strlcpy(g_settings.libretro, libretro_core_installed, sizeof(g_settings.libretro)); + else + find_libretro_file = true; set_default_settings(); - init_settings(load_libretro_path); + rarch_config_load(SYS_CONFIG_FILE, LIBRETRO_DIR_PATH, ".SELF", find_libretro_file); init_libretro_sym(); #if(CELL_SDK_VERSION > 0x340000) @@ -523,13 +376,16 @@ int main(int argc, char *argv[]) case EXTERN_LAUNCHER_SALAMANDER: g_console.mode_switch = MODE_MENU; break; +#ifdef HAVE_MULTIMAN case EXTERN_LAUNCHER_MULTIMAN: RARCH_LOG("Started from multiMAN, will auto-start game.\n"); - strncpy(g_console.rom_path, argv[1], sizeof(g_console.rom_path)); - g_console.initialize_rarch_enable = 1; - g_console.mode_switch = MODE_EMULATION; + strlcpy(g_console.rom_path, argv[1], sizeof(g_console.rom_path)); + rarch_settings_change(S_START_RARCH); rarch_startup(SYS_CONFIG_FILE); break; +#endif + default: + break; } begin_loop: @@ -557,9 +413,11 @@ begin_loop: begin_shutdown: if(path_file_exists(SYS_CONFIG_FILE)) - save_settings(); + rarch_config_save(SYS_CONFIG_FILE); + if(g_console.emulator_initialized) rarch_main_deinit(); + input_ps3.free(NULL); video_gl.stop(); diff --git a/ps3/menu-entries.h b/ps3/menu-entries.h index 4c9b59c1e7..8968bd581e 100644 --- a/ps3/menu-entries.h +++ b/ps3/menu-entries.h @@ -103,665 +103,678 @@ static item items_generalsettings[MAX_NO_OF_CONTROLS_SETTINGS] = 1 }, { - SETTING_HW_TEXTURE_FILTER, - "Hardware Filtering shader #1", - "", - 0.0f, - 0.0f, - YELLOW, - "INFO - Hardware filtering is set to 'Bilinear filtering' for [Shader #1].", - WHITE, - 0.91f, - 0.09f, - 0.83f, - 1, - 1 + SETTING_HW_TEXTURE_FILTER, + "Hardware Filtering shader #1", + "", + 0.0f, + 0.0f, + YELLOW, + "INFO - Hardware filtering is set to 'Bilinear filtering' for [Shader #1].", + WHITE, + 0.91f, + 0.09f, + 0.83f, + 1, + 1 }, { - SETTING_HW_TEXTURE_FILTER_2, - "Hardware Filtering shader #2", - "", - 0.0f, - 0.0f, - YELLOW, - "INFO - Hardware filtering is set to 'Bilinear filtering' for [Shader #2].", - WHITE, - 0.91f, - 0.09f, - 0.83f, - 1, - 1 + SETTING_HW_TEXTURE_FILTER_2, + "Hardware Filtering shader #2", + "", + 0.0f, + 0.0f, + YELLOW, + "INFO - Hardware filtering is set to 'Bilinear filtering' for [Shader #2].", + WHITE, + 0.91f, + 0.09f, + 0.83f, + 1, + 1 }, { - SETTING_SCALE_ENABLED, - "Custom Scaling/Dual Shaders", - "", - 0.0f, - 0.0f, - YELLOW, - "INFO - [Custom Scaling] is set to 'ON' - 2x shaders will look much\nbetter, and you can select a shader for [Shader #2].", - WHITE, - 0.91f, - 0.09f, - 0.83f, - 1, - 1 + SETTING_SCALE_ENABLED, + "Custom Scaling/Dual Shaders", + "", + 0.0f, + 0.0f, + YELLOW, + "INFO - [Custom Scaling] is set to 'ON' - 2x shaders will look much\nbetter, and you can select a shader for [Shader #2].", + WHITE, + 0.91f, + 0.09f, + 0.83f, + 1, + 1 }, { - SETTING_SCALE_FACTOR, - "Custom Scaling Factor", - "", - 0.0f, - 0.0f, - YELLOW, - "INFO - [Custom Scaling Factor] is set to '2x'.", - WHITE, - 0.91f, - 0.09f, - 0.83f, - 2, - 1 + SETTING_SCALE_FACTOR, + "Custom Scaling Factor", + "", + 0.0f, + 0.0f, + YELLOW, + "INFO - [Custom Scaling Factor] is set to '2x'.", + WHITE, + 0.91f, + 0.09f, + 0.83f, + 2, + 1 }, { - SETTING_HW_OVERSCAN_AMOUNT, - "Overscan", - "", - 0.0f, - 0.0f, - YELLOW, - "INFO - Adjust or decrease [Overscan]. Set this to higher than 0.000\nif the screen doesn't fit on your TV/monitor.", - WHITE, - 0.91f, - 0.09f, - 0.83f, - 0, - 1 + SETTING_HW_OVERSCAN_AMOUNT, + "Overscan", + "", + 0.0f, + 0.0f, + YELLOW, + "INFO - Adjust or decrease [Overscan]. Set this to higher than 0.000\nif the screen doesn't fit on your TV/monitor.", + WHITE, + 0.91f, + 0.09f, + 0.83f, + 0, + 1 }, { - SETTING_THROTTLE_MODE, - "Throttle Mode", - "", - 0.0f, - 0.0f, - YELLOW, - "INFO - [Throttle Mode] is set to 'ON' - VSync is enabled and sound\nis turned on.", - WHITE, - 0.91f, - 0.09f, - 0.83f, - 1, - 1 + SETTING_THROTTLE_MODE, + "Throttle Mode", + "", + 0.0f, + 0.0f, + YELLOW, + "INFO - [Throttle Mode] is set to 'ON' - VSync is enabled and sound\nis turned on.", + WHITE, + 0.91f, + 0.09f, + 0.83f, + 1, + 1 }, { - SETTING_TRIPLE_BUFFERING, - "Triple Buffering", - "", - 0.0f, - 0.0f, - YELLOW, - "INFO - [Triple Buffering] is set to 'ON' - faster graphics/shaders at\nthe possible expense of input lag.", - WHITE, - 0.91f, - 0.09f, - 0.83f, - 1, - 1 + SETTING_TRIPLE_BUFFERING, + "Triple Buffering", + "", + 0.0f, + 0.0f, + YELLOW, + "INFO - [Triple Buffering] is set to 'ON' - faster graphics/shaders at\nthe possible expense of input lag.", + WHITE, + 0.91f, + 0.09f, + 0.83f, + 1, + 1 }, { - SETTING_ENABLE_SCREENSHOTS, - "Enable Screenshots Feature", - "", - 0.0f, - 0.0f, - YELLOW, - "INFO - [Enable Screenshots] feature is set to 'OFF'.", - WHITE, - 0.91f, - 0.09f, - 0.83f, - 1, - 1 + SETTING_ENABLE_SCREENSHOTS, + "Enable Screenshots Feature", + "", + 0.0f, + 0.0f, + YELLOW, + "INFO - [Enable Screenshots] feature is set to 'OFF'.", + WHITE, + 0.91f, + 0.09f, + 0.83f, + 1, + 1 }, { - SETTING_SAVE_SHADER_PRESET, - "SAVE SETTINGS AS CGP PRESET ", - "", - 0.0f, - 0.0f, - YELLOW, - "INFO - Save the current video settings to a [CG Preset] (CGP) file.", - GREEN, - 0.91f, - 0.09f, - 0.83f, - 0, - 1 + SETTING_SAVE_SHADER_PRESET, + "SAVE SETTINGS AS CGP PRESET ", + "", + 0.0f, + 0.0f, + YELLOW, + "INFO - Save the current video settings to a [CG Preset] (CGP) file.", + GREEN, + 0.91f, + 0.09f, + 0.83f, + 0, + 1 }, { - SETTING_APPLY_SHADER_PRESET_ON_STARTUP, - "APPLY SHADER PRESET ON STARTUP", - "", - 0.0f, - 0.0f, - YELLOW, - "INFO - Automatically load the currently selected [CG Preset] file on startup.", - GREEN, - 0.91f, - 0.09f, - 0.83f, - 0, - 1 + SETTING_APPLY_SHADER_PRESET_ON_STARTUP, + "APPLY SHADER PRESET ON STARTUP", + "", + 0.0f, + 0.0f, + YELLOW, + "INFO - Automatically load the currently selected [CG Preset] file on startup.", + GREEN, + 0.91f, + 0.09f, + 0.83f, + 0, + 1 }, { - SETTING_DEFAULT_VIDEO_ALL, - "DEFAULT", - "", - 0.0f, - 0.0f, - YELLOW, - "INFO - Set all [General Video Settings] back to their 'DEFAULT' values.", - GREEN, - 0.91f, - 0.09f, - 0.83f, - 0, - 1 + SETTING_DEFAULT_VIDEO_ALL, + "DEFAULT", + "", + 0.0f, + 0.0f, + YELLOW, + "INFO - Set all [General Video Settings] back to their 'DEFAULT' values.", + GREEN, + 0.91f, + 0.09f, + 0.83f, + 0, + 1 }, { - SETTING_SOUND_MODE, - "Sound Output", - "", - 0.0f, - 0.0f, - YELLOW, - "INFO - [Sound Output] is set to 'Normal' - normal audio output will be\nused.", - WHITE, - 0.91f, - 0.09f, - 0.83f, - 0, - 1 + SETTING_SOUND_MODE, + "Sound Output", + "", + 0.0f, + 0.0f, + YELLOW, + "INFO - [Sound Output] is set to 'Normal' - normal audio output will be\nused.", + WHITE, + 0.91f, + 0.09f, + 0.83f, + 0, + 1 }, { - SETTING_RSOUND_SERVER_IP_ADDRESS, - "RSound Audio Server IP Address", - "", - 0.0f, - 0.0f, - YELLOW, - "INFO - Enter the IP Address of the [RSound Audio Server]. IP address\nmust be an IPv4 32-bits address, eg: '192.168.1.7'.", - WHITE, - 0.91f, - 0.09f, - 0.83f, - 0, - 1 + SETTING_RSOUND_SERVER_IP_ADDRESS, + "RSound Audio Server IP Address", + "", + 0.0f, + 0.0f, + YELLOW, + "INFO - Enter the IP Address of the [RSound Audio Server]. IP address\nmust be an IPv4 32-bits address, eg: '192.168.1.7'.", + WHITE, + 0.91f, + 0.09f, + 0.83f, + 0, + 1 }, { - SETTING_ENABLE_CUSTOM_BGM, - "Enable Custom BGM Feature", - "", - 0.0f, - 0.0f, - YELLOW, - "INFO - [Enable Custom BGM] feature is set to 'ON'.", - WHITE, - 0.91f, - 0.09f, - 0.83f, - 1, - 1 + SETTING_ENABLE_CUSTOM_BGM, + "Enable Custom BGM Feature", + "", + 0.0f, + 0.0f, + YELLOW, + "INFO - [Enable Custom BGM] feature is set to 'ON'.", + WHITE, + 0.91f, + 0.09f, + 0.83f, + 1, + 1 }, { - SETTING_DEFAULT_AUDIO_ALL, - "DEFAULT", - "", - 0.0f, - 0.0f, - YELLOW, - "INFO - Set all [General Audio Settings] back to their 'DEFAULT' values.", - GREEN, - 0.91f, - 0.09f, - 0.83f, - 0, - 1 - }, - /* port-specific */ - { - SETTING_EMU_CURRENT_SAVE_STATE_SLOT, - "Current save state slot", - "", - 0.0f, - 0.0f, - YELLOW, - "INFO - Set the current savestate slot (can also be configured ingame).", - WHITE, - 0.91f, - 0.09f, - 0.83f, - 0, - 1 + SETTING_DEFAULT_AUDIO_ALL, + "DEFAULT", + "", + 0.0f, + 0.0f, + YELLOW, + "INFO - Set all [General Audio Settings] back to their 'DEFAULT' values.", + GREEN, + 0.91f, + 0.09f, + 0.83f, + 0, + 1 }, { - SETTING_RARCH_DEFAULT_EMU, - "Default emulator core", - "", - 0.0f, - 0.0f, - YELLOW, - "INFO - Select a default emulator core to launch at start-up.", - WHITE, - 0.91f, - 0.09f, - 0.83f, - 0, - 1 + SETTING_EMU_CURRENT_SAVE_STATE_SLOT, + "Current save state slot", + "", + 0.0f, + 0.0f, + YELLOW, + "INFO - Set the current savestate slot (can also be configured ingame).", + WHITE, + 0.91f, + 0.09f, + 0.83f, + 0, + 1 }, { - SETTING_EMU_DEFAULT_ALL, - "DEFAULT", - "", - 0.0f, - 0.0f, - YELLOW, - "INFO - Set [all RetroArch settings] back to their 'DEFAULT' values.", - GREEN, - 0.91f, - 0.09f, - 0.83f, - 0, - 1 + SETTING_EMU_SHOW_INFO_MSG, + "Info messages", + "", + 0.0f, + 0.0f, + YELLOW, + "INFO - Show onscreen info messages in the menu.", + WHITE, + 0.91f, + 0.09f, + 0.83f, + 0, + 1 }, { - SETTING_EMU_REWIND_ENABLED, - "Rewind", - "", - 0.0f, - 0.0f, - YELLOW, - "INFO - [Rewind] feature is set to 'OFF'.", - WHITE, - 0.91f, - 0.09f, - 0.83f, - 0, - 1 + SETTING_RARCH_DEFAULT_EMU, + "Default emulator core", + "", + 0.0f, + 0.0f, + YELLOW, + "INFO - Select a default emulator core to launch at start-up.", + WHITE, + 0.91f, + 0.09f, + 0.83f, + 0, + 1 }, { - SETTING_EMU_VIDEO_DEFAULT_ALL, - "DEFAULT", - "", - 0.0f, - 0.0f, - YELLOW, - "INFO - Set [all RetroArch Video settings] back to their 'DEFAULT' values.", - GREEN, - 0.91f, - 0.09f, - 0.83f, - 0, - 1 + SETTING_EMU_DEFAULT_ALL, + "DEFAULT", + "", + 0.0f, + 0.0f, + YELLOW, + "INFO - Set [all RetroArch settings] back to their 'DEFAULT' values.", + GREEN, + 0.91f, + 0.09f, + 0.83f, + 0, + 1 }, { - SETTING_EMU_AUDIO_MUTE, - "Mute Audio", - "", - 0.0f, - 0.0f, - YELLOW, - "INFO - [Mute Audio] is set to 'OFF'.", - WHITE, - 0.91f, - 0.09f, - 0.83f, - 0, - 1 + SETTING_EMU_REWIND_ENABLED, + "Rewind", + "", + 0.0f, + 0.0f, + YELLOW, + "INFO - [Rewind] feature is set to 'OFF'.", + WHITE, + 0.91f, + 0.09f, + 0.83f, + 0, + 1 }, { - SETTING_EMU_AUDIO_DEFAULT_ALL, - "DEFAULT", - "", - 0.0f, - 0.0f, - YELLOW, - "INFO - Set [all RetroArch Audio settings] back to their 'DEFAULT' values.", - GREEN, - 0.91f, - 0.09f, - 0.83f, - 0, - 1 - }, - /* end of port-specific */ - { - SETTING_PATH_DEFAULT_ROM_DIRECTORY, - "Startup ROM Directory", - "", - 0.0f, - 0.0f, - YELLOW, - "INFO - Set the default [Startup ROM directory]. NOTE: You will have to\nrestart the emulator for this change to have any effect.", - WHITE, - 0.91f, - 0.09f, - 0.83f, + SETTING_EMU_VIDEO_DEFAULT_ALL, + "DEFAULT", + "", + 0.0f, + 0.0f, + YELLOW, + "INFO - Set [all RetroArch Video settings] back to their 'DEFAULT' values.", + GREEN, + 0.91f, + 0.09f, + 0.83f, + 0, + 1 }, { - SETTING_PATH_SAVESTATES_DIRECTORY, - "Savestate Directory", - "", - 0.0f, - 0.0f, - YELLOW, - "INFO - Set the default path where all the savestate files will be saved to.", - WHITE, - 0.91f, - 0.09f, - 0.83f, + SETTING_EMU_AUDIO_MUTE, + "Mute Audio", + "", + 0.0f, + 0.0f, + YELLOW, + "INFO - [Mute Audio] is set to 'OFF'.", + WHITE, + 0.91f, + 0.09f, + 0.83f, + 0, + 1 }, { - SETTING_PATH_SRAM_DIRECTORY, - "SRAM Directory", - "", - 0.0f, - 0.0f, - YELLOW, - "INFO - Set the default SRAM (SaveRAM) directory path. All the\nbattery backup saves will be stored in this directory.", - WHITE, - 0.91f, - 0.09f, - 0.83f, + SETTING_EMU_AUDIO_DEFAULT_ALL, + "DEFAULT", + "", + 0.0f, + 0.0f, + YELLOW, + "INFO - Set [all RetroArch Audio settings] back to their 'DEFAULT' values.", + GREEN, + 0.91f, + 0.09f, + 0.83f, + 0, + 1 }, { - SETTING_PATH_CHEATS, - "Cheatfile Directory", - "", - 0.0f, - 0.0f, - YELLOW, - "INFO - Set the default [Cheatfile directory] path. All CHT (cheat) files\nwill be stored here.", - WHITE, - 0.91f, - 0.09f, - 0.83f, + SETTING_PATH_DEFAULT_ROM_DIRECTORY, + "Startup ROM Directory", + "", + 0.0f, + 0.0f, + YELLOW, + "INFO - Set the default [Startup ROM directory]. NOTE: You will have to\nrestart the emulator for this change to have any effect.", + WHITE, + 0.91f, + 0.09f, + 0.83f, }, { - SETTING_ENABLE_SRAM_PATH, - "Custom SRAM Dir Path", - "", - 0.0f, - 0.0f, - YELLOW, - "INFO - [Custom SRAM Dir Path] feature is set to 'OFF'.", - WHITE, - 0.91f, - 0.09f, - 0.83f, - 1, - 1 + SETTING_PATH_SAVESTATES_DIRECTORY, + "Savestate Directory", + "", + 0.0f, + 0.0f, + YELLOW, + "INFO - Set the default path where all the savestate files will be saved to.", + WHITE, + 0.91f, + 0.09f, + 0.83f, }, { - SETTING_ENABLE_STATE_PATH, - "Custom Save State Dir Path", - "", - 0.0f, - 0.0f, - YELLOW, - "INFO - [Custom Save State Dir Path] feature is set to 'OFF'.", - WHITE, - 0.91f, - 0.09f, - 0.83f, - 1, - 1 + SETTING_PATH_SRAM_DIRECTORY, + "SRAM Directory", + "", + 0.0f, + 0.0f, + YELLOW, + "INFO - Set the default SRAM (SaveRAM) directory path. All the\nbattery backup saves will be stored in this directory.", + WHITE, + 0.91f, + 0.09f, + 0.83f, }, { - SETTING_PATH_DEFAULT_ALL, - "DEFAULT", - "", - 0.0f, - 0.0f, - YELLOW, - "INFO - Set [all Path settings] back to their 'DEFAULT' values.", - GREEN, - 0.91f, - 0.09f, - 0.83f, + SETTING_PATH_CHEATS, + "Cheatfile Directory", + "", + 0.0f, + 0.0f, + YELLOW, + "INFO - Set the default [Cheatfile directory] path. All CHT (cheat) files\nwill be stored here.", + WHITE, + 0.91f, + 0.09f, + 0.83f, }, { - SETTING_CONTROLS_SCHEME, - "Control Scheme Preset", - "", - 0.0f, - 0.0f, - YELLOW, - "", - WHITE, - 0.91f, - 0.09f, - 0.83f, + SETTING_ENABLE_SRAM_PATH, + "Custom SRAM Dir Path", + "", + 0.0f, + 0.0f, + YELLOW, + "INFO - [Custom SRAM Dir Path] feature is set to 'OFF'.", + WHITE, + 0.91f, + 0.09f, + 0.83f, + 1, + 1 }, { - SETTING_CONTROLS_NUMBER, - "Controller No", - "", - 0.0f, - 0.0f, - YELLOW, - "", - WHITE, - 0.91f, - 0.09f, - 0.83f, + SETTING_ENABLE_STATE_PATH, + "Custom Save State Dir Path", + "", + 0.0f, + 0.0f, + YELLOW, + "INFO - [Custom Save State Dir Path] feature is set to 'OFF'.", + WHITE, + 0.91f, + 0.09f, + 0.83f, + 1, + 1 }, { - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_B, - "B Button", - "", - 0.0f, - 0.0f, - YELLOW, - "", - WHITE, - 0.91f, - 0.09f, - 0.83f, + SETTING_PATH_DEFAULT_ALL, + "DEFAULT", + "", + 0.0f, + 0.0f, + YELLOW, + "INFO - Set [all Path settings] back to their 'DEFAULT' values.", + GREEN, + 0.91f, + 0.09f, + 0.83f, }, { - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_Y, - "Y Button", - "", - 0.0f, - 0.0f, - YELLOW, - "", - WHITE, - 0.91f, - 0.09f, - 0.83f, + SETTING_CONTROLS_SCHEME, + "Control Scheme Preset", + "", + 0.0f, + 0.0f, + YELLOW, + "", + WHITE, + 0.91f, + 0.09f, + 0.83f, }, { - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_SELECT, - "Select button", - "", - 0.0f, - 0.0f, - YELLOW, - "", - WHITE, - 0.91f, - 0.09f, - 0.83f, + SETTING_CONTROLS_NUMBER, + "Controller No", + "", + 0.0f, + 0.0f, + YELLOW, + "", + WHITE, + 0.91f, + 0.09f, + 0.83f, }, { - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_START, - "Start button", - "", - 0.0f, - 0.0f, - YELLOW, - "", - WHITE, - 0.91f, - 0.09f, - 0.83f, + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_B, + "B Button", + "", + 0.0f, + 0.0f, + YELLOW, + "", + WHITE, + 0.91f, + 0.09f, + 0.83f, }, { - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_UP, - "D-Pad Up", - "", - 0.0f, - 0.0f, - YELLOW, - "", - WHITE, - 0.91f, - 0.09f, - 0.83f, + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_Y, + "Y Button", + "", + 0.0f, + 0.0f, + YELLOW, + "", + WHITE, + 0.91f, + 0.09f, + 0.83f, }, { - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_DOWN, - "D-Pad Down", - "", - 0.0f, - 0.0f, - YELLOW, - "", - WHITE, - 0.91f, - 0.09f, - 0.83f, + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_SELECT, + "Select button", + "", + 0.0f, + 0.0f, + YELLOW, + "", + WHITE, + 0.91f, + 0.09f, + 0.83f, }, { - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_LEFT, - "D-Pad Left", - "", - 0.0f, - 0.0f, - YELLOW, - "", - WHITE, - 0.91f, - 0.09f, - 0.83f, + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_START, + "Start button", + "", + 0.0f, + 0.0f, + YELLOW, + "", + WHITE, + 0.91f, + 0.09f, + 0.83f, }, { - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_RIGHT, - "D-Pad Right", - "", - 0.0f, - 0.0f, - YELLOW, - "", - WHITE, - 0.91f, - 0.09f, - 0.83f, + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_UP, + "D-Pad Up", + "", + 0.0f, + 0.0f, + YELLOW, + "", + WHITE, + 0.91f, + 0.09f, + 0.83f, }, { - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_A, - "A Button", - "", - 0.0f, - 0.0f, - YELLOW, - "", - WHITE, - 0.91f, - 0.09f, - 0.83f, + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_DOWN, + "D-Pad Down", + "", + 0.0f, + 0.0f, + YELLOW, + "", + WHITE, + 0.91f, + 0.09f, + 0.83f, }, { - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_X, - "X Button", - "", - 0.0f, - 0.0f, - YELLOW, - "", - WHITE, - 0.91f, - 0.09f, - 0.83f, + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_LEFT, + "D-Pad Left", + "", + 0.0f, + 0.0f, + YELLOW, + "", + WHITE, + 0.91f, + 0.09f, + 0.83f, }, { - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_L, - "L Button", - "", - 0.0f, - 0.0f, - YELLOW, - "", - WHITE, - 0.91f, - 0.09f, - 0.83f, + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_RIGHT, + "D-Pad Right", + "", + 0.0f, + 0.0f, + YELLOW, + "", + WHITE, + 0.91f, + 0.09f, + 0.83f, }, { - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_R, - "R Button", - "", - 0.0f, - 0.0f, - YELLOW, - "", - WHITE, - 0.91f, - 0.09f, - 0.83f, + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_A, + "A Button", + "", + 0.0f, + 0.0f, + YELLOW, + "", + WHITE, + 0.91f, + 0.09f, + 0.83f, }, { - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_L2, - "L2 Button", - "", - 0.0f, - 0.0f, - YELLOW, - "", - WHITE, - 0.91f, - 0.09f, - 0.83f, + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_X, + "X Button", + "", + 0.0f, + 0.0f, + YELLOW, + "", + WHITE, + 0.91f, + 0.09f, + 0.83f, }, { - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_R2, - "R2 Button", - "", - 0.0f, - 0.0f, - YELLOW, - "", - WHITE, - 0.91f, - 0.09f, - 0.83f, + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_L, + "L Button", + "", + 0.0f, + 0.0f, + YELLOW, + "", + WHITE, + 0.91f, + 0.09f, + 0.83f, }, { - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_L3, - "L3 Button", - "", - 0.0f, - 0.0f, - YELLOW, - "", - WHITE, - 0.91f, - 0.09f, - 0.83f, + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_R, + "R Button", + "", + 0.0f, + 0.0f, + YELLOW, + "", + WHITE, + 0.91f, + 0.09f, + 0.83f, }, { - SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_R3, - "R3 Button", - "", - 0.0f, - 0.0f, - YELLOW, - "", - WHITE, - 0.91f, - 0.09f, - 0.83f, + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_L2, + "L2 Button", + "", + 0.0f, + 0.0f, + YELLOW, + "", + WHITE, + 0.91f, + 0.09f, + 0.83f, + }, + { + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_R2, + "R2 Button", + "", + 0.0f, + 0.0f, + YELLOW, + "", + WHITE, + 0.91f, + 0.09f, + 0.83f, + }, + { + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_L3, + "L3 Button", + "", + 0.0f, + 0.0f, + YELLOW, + "", + WHITE, + 0.91f, + 0.09f, + 0.83f, + }, + { + SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_R3, + "R3 Button", + "", + 0.0f, + 0.0f, + YELLOW, + "", + WHITE, + 0.91f, + 0.09f, + 0.83f, }, { SETTING_CONTROLS_SAVE_CUSTOM_CONTROLS, diff --git a/ps3/menu.c b/ps3/menu.c index 4462100eeb..c1704387f3 100644 --- a/ps3/menu.c +++ b/ps3/menu.c @@ -46,12 +46,13 @@ menu menuStack[25]; int menuStackindex = 0; static bool set_initial_dir_tmpbrowser; +static bool set_libretro_core_as_launch; -char special_action_msg[256]; /* message which should be overlaid on top of the screen */ filebrowser_t browser; /* main file browser->for rom browser*/ filebrowser_t tmpBrowser; /* tmp file browser->for everything else*/ uint32_t set_shader = 0; static uint32_t currently_selected_controller_menu = 0; +static char strw_buffer[PATH_MAX]; static menu menu_filebrowser = { "FILE BROWSER |", /* title*/ @@ -149,6 +150,8 @@ static menu menu_controlssettings = { static void display_menubar(uint32_t menu_enum) { + gl_t *gl = driver.video_data; + cellDbgFontPuts (0.09f, 0.05f, FONT_SIZE, menu_enum == GENERAL_VIDEO_MENU ? RED : GREEN, menu_generalvideosettings.title); cellDbgFontPuts (0.19f, 0.05f, FONT_SIZE, menu_enum == GENERAL_AUDIO_MENU ? RED : GREEN, menu_generalaudiosettings.title); cellDbgFontPuts (0.29f, 0.05f, FONT_SIZE, menu_enum == EMU_GENERAL_MENU ? RED : GREEN, menu_emu_settings.title); @@ -157,7 +160,7 @@ static void display_menubar(uint32_t menu_enum) cellDbgFontPuts (0.09f, 0.09f, FONT_SIZE, menu_enum == PATH_MENU ? RED : GREEN, menu_pathsettings.title); cellDbgFontPuts (0.19f, 0.09f, FONT_SIZE, menu_enum == CONTROLS_MENU ? RED : GREEN, menu_controlssettings.title); cellDbgFontPrintf (0.8f, 0.09f, 0.82f, WHITE, "v%s", EMULATOR_VERSION); - cellDbgFontDraw(); + gl_render_msg_post(gl); } enum @@ -197,7 +200,6 @@ static void set_delay_speed(unsigned delaymode) break; } - strlcpy(special_action_msg, "", sizeof(special_action_msg)); SET_TIMER_EXPIRATION(gl, speed); } @@ -317,9 +319,7 @@ static void browser_update(filebrowser_t * b) } if (CTRL_CIRCLE(button_was_pressed)) - { filebrowser_pop_directory(b); - } old_state = state; } @@ -327,6 +327,7 @@ static void browser_update(filebrowser_t * b) static void browser_render(filebrowser_t * b) { + gl_t *gl = driver.video_data; uint32_t file_count = b->file_count; int current_index, page_number, page_base, i; float currentX, currentY, ySpacing; @@ -343,9 +344,9 @@ static void browser_render(filebrowser_t * b) { currentY = currentY + ySpacing; cellDbgFontPuts(currentX, currentY, FONT_SIZE, i == current_index ? RED : b->cur[i].d_type == CELL_FS_TYPE_DIRECTORY ? GREEN : WHITE, b->cur[i].d_name); - cellDbgFontDraw(); + gl_render_msg_post(gl); } - cellDbgFontDraw(); + gl_render_msg_post(gl); } static void set_setting_label(menu * menu_obj, uint64_t currentsetting) @@ -354,45 +355,45 @@ static void set_setting_label(menu * menu_obj, uint64_t currentsetting) { case SETTING_CHANGE_RESOLUTION: if(g_console.initial_resolution_id == g_console.supported_resolutions[g_console.current_resolution_index]) - menu_obj->items[currentsetting].text_color = GREEN; + menu_obj->items[currentsetting].text_color = GREEN; else - menu_obj->items[currentsetting].text_color = ORANGE; + menu_obj->items[currentsetting].text_color = ORANGE; snprintf(menu_obj->items[currentsetting].setting_text, sizeof(menu_obj->items[currentsetting].setting_text), ps3_get_resolution_label(g_console.supported_resolutions[g_console.current_resolution_index])); break; case SETTING_SHADER_PRESETS: { - char fname[MAX_PATH_LENGTH]; - if(g_console.cgp_path == DEFAULT_PRESET_FILE) - menu_obj->items[currentsetting].text_color = GREEN; - else - menu_obj->items[currentsetting].text_color = ORANGE; - fill_pathname_base(fname, g_console.cgp_path, sizeof(fname)); - snprintf(menu_obj->items[currentsetting].setting_text, sizeof(menu_obj->items[currentsetting].setting_text), fname); + char fname[PATH_MAX]; + if(g_console.cgp_path == DEFAULT_PRESET_FILE) + menu_obj->items[currentsetting].text_color = GREEN; + else + menu_obj->items[currentsetting].text_color = ORANGE; + fill_pathname_base(fname, g_console.cgp_path, sizeof(fname)); + snprintf(menu_obj->items[currentsetting].setting_text, sizeof(menu_obj->items[currentsetting].setting_text), fname); } break; case SETTING_SHADER: { - char fname[MAX_PATH_LENGTH]; - fill_pathname_base(fname, g_settings.video.cg_shader_path, sizeof(fname)); - snprintf(menu_obj->items[currentsetting].setting_text, sizeof(menu_obj->items[currentsetting].setting_text), "%s", fname); + char fname[PATH_MAX]; + fill_pathname_base(fname, g_settings.video.cg_shader_path, sizeof(fname)); + snprintf(menu_obj->items[currentsetting].setting_text, sizeof(menu_obj->items[currentsetting].setting_text), "%s", fname); - if(strcmp(g_settings.video.cg_shader_path,DEFAULT_SHADER_FILE) == 0) - menu_obj->items[currentsetting].text_color = GREEN; - else - menu_obj->items[currentsetting].text_color = ORANGE; + if(strcmp(g_settings.video.cg_shader_path,DEFAULT_SHADER_FILE) == 0) + menu_obj->items[currentsetting].text_color = GREEN; + else + menu_obj->items[currentsetting].text_color = ORANGE; } break; case SETTING_SHADER_2: { - char fname[MAX_PATH_LENGTH]; - fill_pathname_base(fname, g_settings.video.second_pass_shader, sizeof(fname)); - snprintf(menu_obj->items[currentsetting].setting_text, sizeof(menu_obj->items[currentsetting].setting_text), "%s", fname); + char fname[PATH_MAX]; + fill_pathname_base(fname, g_settings.video.second_pass_shader, sizeof(fname)); + snprintf(menu_obj->items[currentsetting].setting_text, sizeof(menu_obj->items[currentsetting].setting_text), "%s", fname); - if(strcmp(g_settings.video.second_pass_shader,DEFAULT_SHADER_FILE) == 0) - menu_obj->items[currentsetting].text_color = GREEN; - else - menu_obj->items[currentsetting].text_color = ORANGE; + if(strcmp(g_settings.video.second_pass_shader,DEFAULT_SHADER_FILE) == 0) + menu_obj->items[currentsetting].text_color = GREEN; + else + menu_obj->items[currentsetting].text_color = ORANGE; } break; case SETTING_FONT_SIZE: @@ -547,6 +548,18 @@ static void set_setting_label(menu * menu_obj, uint64_t currentsetting) snprintf(menu_obj->items[currentsetting].setting_text, sizeof(menu_obj->items[currentsetting].setting_text), "%d", g_extern.state_slot); break; /* emu-specific */ + case SETTING_EMU_SHOW_INFO_MSG: + if(g_console.info_msg_enable) + { + snprintf(menu_obj->items[currentsetting].setting_text, sizeof(menu_obj->items[currentsetting].setting_text), "ON"); + menu_obj->items[currentsetting].text_color = GREEN; + } + else + { + snprintf(menu_obj->items[currentsetting].setting_text, sizeof(menu_obj->items[currentsetting].setting_text), "OFF"); + menu_obj->items[currentsetting].text_color = ORANGE; + } + break; case SETTING_EMU_DEFAULT_ALL: if(menu_obj->selected == currentsetting) menu_obj->items[currentsetting].text_color = GREEN; @@ -569,7 +582,7 @@ static void set_setting_label(menu * menu_obj, uint64_t currentsetting) break; case SETTING_RARCH_DEFAULT_EMU: { - char fname[MAX_PATH_LENGTH]; + char fname[PATH_MAX]; fill_pathname_base(fname, g_settings.libretro, sizeof(fname)); snprintf(menu_obj->items[currentsetting].setting_text, sizeof(menu_obj->items[currentsetting].setting_text), "%s", fname); @@ -724,15 +737,15 @@ static void set_setting_label(menu * menu_obj, uint64_t currentsetting) break; case SETTING_CONTROLS_SAVE_CUSTOM_CONTROLS: if(menu_obj->selected == currentsetting) - menu_obj->items[currentsetting].text_color = GREEN; + menu_obj->items[currentsetting].text_color = GREEN; else - menu_obj->items[currentsetting].text_color = ORANGE; + menu_obj->items[currentsetting].text_color = ORANGE; break; case SETTING_CONTROLS_DEFAULT_ALL: if(menu_obj->selected == currentsetting) - menu_obj->items[currentsetting].text_color = GREEN; + menu_obj->items[currentsetting].text_color = GREEN; else - menu_obj->items[currentsetting].text_color = ORANGE; + menu_obj->items[currentsetting].text_color = ORANGE; break; default: break; @@ -803,8 +816,8 @@ static void apply_scaling (unsigned init_mode) static void select_file(uint32_t menu_id) { - char extensions[256], title[256], object[256], comment[256], dir_path[MAX_PATH_LENGTH], - path[MAX_PATH_LENGTH], *separatorslash; + char extensions[256], title[256], object[256], comment[256], dir_path[PATH_MAX], + path[PATH_MAX], *separatorslash; uint64_t state, diff_state, button_was_pressed; gl_t * gl = driver.video_data; @@ -815,43 +828,43 @@ static void select_file(uint32_t menu_id) switch(menu_id) { case SHADER_CHOICE: - strncpy(dir_path, SHADERS_DIR_PATH, sizeof(dir_path)); - strncpy(extensions, "cg|CG", sizeof(extensions)); - strncpy(title, "SHADER SELECTION", sizeof(title)); - strncpy(object, "Shader", sizeof(object)); - strncpy(comment, "INFO - Select a shader from the menu by pressing the X button.", sizeof(comment)); + strlcpy(dir_path, SHADERS_DIR_PATH, sizeof(dir_path)); + strlcpy(extensions, "cg|CG", sizeof(extensions)); + strlcpy(title, "SHADER SELECTION", sizeof(title)); + strlcpy(object, "Shader", sizeof(object)); + strlcpy(comment, "INFO - Select a shader from the menu by pressing the X button.", sizeof(comment)); break; case PRESET_CHOICE: - strncpy(dir_path, PRESETS_DIR_PATH, sizeof(dir_path)); - strncpy(extensions, "cgp|CGP", sizeof(extensions)); - strncpy(title, "SHADER PRESETS SELECTION", sizeof(title)); - strncpy(object, "Shader", sizeof(object)); - strncpy(object, "Shader preset", sizeof(object)); - strncpy(comment, "INFO - Select a shader preset from the menu by pressing the X button.", sizeof(comment)); + strlcpy(dir_path, PRESETS_DIR_PATH, sizeof(dir_path)); + strlcpy(extensions, "cgp|CGP", sizeof(extensions)); + strlcpy(title, "SHADER PRESETS SELECTION", sizeof(title)); + strlcpy(object, "Shader", sizeof(object)); + strlcpy(object, "Shader preset", sizeof(object)); + strlcpy(comment, "INFO - Select a shader preset from the menu by pressing the X button.", sizeof(comment)); break; case INPUT_PRESET_CHOICE: - strncpy(dir_path, INPUT_PRESETS_DIR_PATH, sizeof(dir_path)); - strncpy(extensions, "cfg|CFG", sizeof(extensions)); - strncpy(title, "INPUT PRESETS SELECTION", sizeof(title)); - strncpy(object, "Input", sizeof(object)); - strncpy(object, "Input preset", sizeof(object)); - strncpy(comment, "INFO - Select an input preset from the menu by pressing the X button.", sizeof(comment)); + strlcpy(dir_path, INPUT_PRESETS_DIR_PATH, sizeof(dir_path)); + strlcpy(extensions, "cfg|CFG", sizeof(extensions)); + strlcpy(title, "INPUT PRESETS SELECTION", sizeof(title)); + strlcpy(object, "Input", sizeof(object)); + strlcpy(object, "Input preset", sizeof(object)); + strlcpy(comment, "INFO - Select an input preset from the menu by pressing the X button.", sizeof(comment)); break; case BORDER_CHOICE: - strncpy(dir_path, BORDERS_DIR_PATH, sizeof(dir_path)); - strncpy(extensions, "png|PNG|jpg|JPG|JPEG|jpeg", sizeof(extensions)); - strncpy(title, "BORDER SELECTION", sizeof(title)); - strncpy(object, "Border", sizeof(object)); - strncpy(object, "Border image file", sizeof(object)); - strncpy(comment, "INFO - Select a border image file from the menu by pressing the X button.", sizeof(comment)); + strlcpy(dir_path, BORDERS_DIR_PATH, sizeof(dir_path)); + strlcpy(extensions, "png|PNG|jpg|JPG|JPEG|jpeg", sizeof(extensions)); + strlcpy(title, "BORDER SELECTION", sizeof(title)); + strlcpy(object, "Border", sizeof(object)); + strlcpy(object, "Border image file", sizeof(object)); + strlcpy(comment, "INFO - Select a border image file from the menu by pressing the X button.", sizeof(comment)); break; case LIBRETRO_CHOICE: - strncpy(dir_path, LIBRETRO_DIR_PATH, sizeof(dir_path)); - strncpy(extensions, "self|SELF|bin|BIN", sizeof(extensions)); - strncpy(title, "LIBRETRO CORE SELECTION", sizeof(title)); - strncpy(object, "Libretro", sizeof(object)); - strncpy(object, "Libretro core library", sizeof(object)); - strncpy(comment, "INFO - Select a Libretro core from the menu by pressing the X button.", sizeof(comment)); + strlcpy(dir_path, LIBRETRO_DIR_PATH, sizeof(dir_path)); + strlcpy(extensions, "self|SELF|bin|BIN", sizeof(extensions)); + strlcpy(title, "LIBRETRO CORE SELECTION", sizeof(title)); + strlcpy(object, "Libretro", sizeof(object)); + strlcpy(object, "Libretro core library", sizeof(object)); + strlcpy(comment, "INFO - Select a Libretro core from the menu by pressing the X button.", sizeof(comment)); break; } @@ -875,9 +888,7 @@ static void select_file(uint32_t menu_id) /*if 'filename' is in fact '..' - then pop back directory instead of adding '..' to filename path */ if(tmpBrowser.currently_selected == 0) - { filebrowser_pop_directory(&tmpBrowser); - } else { separatorslash = (strcmp(FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(tmpBrowser),"/") == 0) ? "" : "/"; @@ -920,10 +931,12 @@ static void select_file(uint32_t menu_id) break; case LIBRETRO_CHOICE: strlcpy(g_settings.libretro, path, sizeof(g_settings.libretro)); - strlcpy(g_console.launch_app_on_exit, path, sizeof(g_console.launch_app_on_exit)); - g_console.return_to_launcher = true; - g_console.menu_enable = false; - g_console.mode_switch = MODE_EXIT; + if(set_libretro_core_as_launch) + { + strlcpy(g_console.launch_app_on_exit, path, sizeof(g_console.launch_app_on_exit)); + set_libretro_core_as_launch = false; + rarch_settings_change(S_RETURN_TO_LAUNCHER); + } break; } @@ -939,7 +952,7 @@ static void select_file(uint32_t menu_id) cellDbgFontPuts (0.09f, 0.05f, FONT_SIZE, RED, title); cellDbgFontPrintf(0.09f, 0.92f, 0.92, YELLOW, "X - Select %s /\\ - return to settings START - Reset Startdir", object); cellDbgFontPrintf(0.09f, 0.83f, 0.91f, LIGHTBLUE, "%s", comment); - cellDbgFontDraw(); + gl_render_msg_post(gl); browser_render(&tmpBrowser); old_state = state; @@ -957,8 +970,8 @@ static void select_directory(uint32_t menu_id) if(set_initial_dir_tmpbrowser) { - filebrowser_new(&tmpBrowser, "/\0", "empty"); - set_initial_dir_tmpbrowser = false; + filebrowser_new(&tmpBrowser, "/\0", "empty"); + set_initial_dir_tmpbrowser = false; } browser_update(&tmpBrowser); @@ -1021,9 +1034,7 @@ static void select_directory(uint32_t menu_id) * adding '..' to filename path */ if(tmpBrowser.currently_selected == 0) - { filebrowser_pop_directory(&tmpBrowser); - } else { separatorslash = (strcmp(FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(tmpBrowser),"/") == 0) ? "" : "/"; @@ -1041,7 +1052,7 @@ static void select_directory(uint32_t menu_id) "X - Enter dir /\\ - return to settings START - Reset Startdir"); cellDbgFontPrintf(0.09f, 0.83f, 0.91f, LIGHTBLUE, "%s", "INFO - Browse to a directory and assign it as the path by\npressing SQUARE button."); - cellDbgFontDraw(); + gl_render_msg_post(gl); browser_render(&tmpBrowser); old_state = state; @@ -1069,7 +1080,7 @@ static void set_keybind_digital(uint64_t state, uint64_t default_retro_joypad_id static void rarch_filename_input_and_save (unsigned filename_type) { bool filename_entered = false; - char filename_tmp[256], filepath[MAX_PATH_LENGTH]; + char filename_tmp[256], filepath[PATH_MAX]; oskutil_write_initial_message(&g_console.oskutil_handle, L"example"); oskutil_write_message(&g_console.oskutil_handle, L"Enter filename for preset (with no file extension)"); @@ -1086,7 +1097,7 @@ static void rarch_filename_input_and_save (unsigned filename_type) if(g_console.oskutil_handle.text_can_be_fetched) { - strncpy(filename_tmp, OUTPUT_TEXT_STRING(g_console.oskutil_handle), sizeof(filename_tmp)); + strlcpy(filename_tmp, OUTPUT_TEXT_STRING(g_console.oskutil_handle), sizeof(filename_tmp)); switch(filename_type) { case CONFIG_FILE: @@ -1158,29 +1169,29 @@ static void producesettingentry(menu * menu_obj, uint64_t switchvalue) case SETTING_CHANGE_RESOLUTION: if(CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state) ) { - ps3_next_resolution(); - set_delay = DELAY_SMALL; + ps3_next_resolution(); + set_delay = DELAY_SMALL; } if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) ) { - ps3_previous_resolution(); - set_delay = DELAY_SMALL; + ps3_previous_resolution(); + set_delay = DELAY_SMALL; } if(CTRL_CROSS(state)) { - if (g_console.supported_resolutions[g_console.current_resolution_index] == CELL_VIDEO_OUT_RESOLUTION_576) - { - if(ps3_check_resolution(CELL_VIDEO_OUT_RESOLUTION_576)) - { - //ps3graphics_set_pal60hz(Settings.PS3PALTemporalMode60Hz); - video_gl.restart(); - } - } - else - { - //ps3graphics_set_pal60hz(0); - video_gl.restart(); - } + if (g_console.supported_resolutions[g_console.current_resolution_index] == CELL_VIDEO_OUT_RESOLUTION_576) + { + if(gfx_ctx_check_resolution(CELL_VIDEO_OUT_RESOLUTION_576)) + { + //ps3graphics_set_pal60hz(Settings.PS3PALTemporalMode60Hz); + video_gl.restart(); + } + } + else + { + //ps3graphics_set_pal60hz(0); + video_gl.restart(); + } } break; /* @@ -1203,52 +1214,52 @@ static void producesettingentry(menu * menu_obj, uint64_t switchvalue) case SETTING_SHADER_PRESETS: if((CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state) || CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_CROSS(state))) { - if(g_console.emulator_initialized) - { - menuStackindex++; - menuStack[menuStackindex] = menu_filebrowser; - menuStack[menuStackindex].enum_id = PRESET_CHOICE; - set_initial_dir_tmpbrowser = true; - set_delay = DELAY_LONG; - } + if(g_console.emulator_initialized) + { + menuStackindex++; + menuStack[menuStackindex] = menu_filebrowser; + menuStack[menuStackindex].enum_id = PRESET_CHOICE; + set_initial_dir_tmpbrowser = true; + set_delay = DELAY_LONG; + } } if(CTRL_START(state)) { - strlcpy(g_console.cgp_path, "", sizeof(g_console.cgp_path)); + strlcpy(g_console.cgp_path, "", sizeof(g_console.cgp_path)); } break; case SETTING_SHADER: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state) || CTRL_CROSS(state)) { - menuStackindex++; - menuStack[menuStackindex] = menu_filebrowser; - menuStack[menuStackindex].enum_id = SHADER_CHOICE; - set_shader = 0; - set_initial_dir_tmpbrowser = true; - set_delay = DELAY_LONG; + menuStackindex++; + menuStack[menuStackindex] = menu_filebrowser; + menuStack[menuStackindex].enum_id = SHADER_CHOICE; + set_shader = 0; + set_initial_dir_tmpbrowser = true; + set_delay = DELAY_LONG; } if(CTRL_START(state)) { - gl_cg_load_shader(1, NULL); - strlcpy(g_settings.video.cg_shader_path, DEFAULT_SHADER_FILE, sizeof(g_settings.video.cg_shader_path)); - menu_reinit_settings(); + gl_cg_load_shader(1, NULL); + strlcpy(g_settings.video.cg_shader_path, DEFAULT_SHADER_FILE, sizeof(g_settings.video.cg_shader_path)); + menu_reinit_settings(); } break; case SETTING_SHADER_2: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state) || CTRL_CROSS(state)) { - menuStackindex++; - menuStack[menuStackindex] = menu_filebrowser; - menuStack[menuStackindex].enum_id = SHADER_CHOICE; - set_shader = 1; - set_initial_dir_tmpbrowser = true; - set_delay = DELAY_LONG; + menuStackindex++; + menuStack[menuStackindex] = menu_filebrowser; + menuStack[menuStackindex].enum_id = SHADER_CHOICE; + set_shader = 1; + set_initial_dir_tmpbrowser = true; + set_delay = DELAY_LONG; } if(CTRL_START(state)) { - gl_cg_load_shader(2, NULL); - strlcpy(g_settings.video.second_pass_shader, DEFAULT_SHADER_FILE, sizeof(g_settings.video.second_pass_shader)); - menu_reinit_settings(); + gl_cg_load_shader(2, NULL); + strlcpy(g_settings.video.second_pass_shader, DEFAULT_SHADER_FILE, sizeof(g_settings.video.second_pass_shader)); + menu_reinit_settings(); } break; case SETTING_FONT_SIZE: @@ -1274,70 +1285,58 @@ static void producesettingentry(menu * menu_obj, uint64_t switchvalue) case SETTING_KEEP_ASPECT_RATIO: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state)) { - if(g_console.aspect_ratio_index > 0) - { - g_console.aspect_ratio_index--; - gfx_ctx_set_aspect_ratio(NULL, g_console.aspect_ratio_index); - set_delay = DELAY_SMALL; - } + rarch_settings_change(S_ASPECT_RATIO_DECREMENT); + gfx_ctx_set_aspect_ratio(NULL, g_console.aspect_ratio_index); + set_delay = DELAY_SMALL; } if(CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state)) { - g_console.aspect_ratio_index++; - if(g_console.aspect_ratio_index < ASPECT_RATIO_END) - { - gfx_ctx_set_aspect_ratio(NULL, g_console.aspect_ratio_index); - set_delay = DELAY_SMALL; - } - else - g_console.aspect_ratio_index = ASPECT_RATIO_END-1; + rarch_settings_change(S_ASPECT_RATIO_INCREMENT); + gfx_ctx_set_aspect_ratio(NULL, g_console.aspect_ratio_index); + set_delay = DELAY_SMALL; } if(CTRL_START(state)) { - g_console.aspect_ratio_index = ASPECT_RATIO_4_3; - gfx_ctx_set_aspect_ratio(NULL, g_console.aspect_ratio_index); + rarch_settings_default(S_DEF_ASPECT_RATIO); + gfx_ctx_set_aspect_ratio(NULL, g_console.aspect_ratio_index); } break; case SETTING_HW_TEXTURE_FILTER: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state) || CTRL_CROSS(state)) { - g_settings.video.smooth = !g_settings.video.smooth; + rarch_settings_change(S_HW_TEXTURE_FILTER); gfx_ctx_set_filtering(1, g_settings.video.smooth); set_delay = DELAY_LONG; } if(CTRL_START(state)) { - g_settings.video.smooth = 1; + rarch_settings_change(S_DEF_HW_TEXTURE_FILTER); gfx_ctx_set_filtering(1, g_settings.video.smooth); } break; case SETTING_HW_TEXTURE_FILTER_2: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state) || CTRL_CROSS(state)) { - g_settings.video.second_pass_smooth = !g_settings.video.second_pass_smooth; + rarch_settings_change(S_HW_TEXTURE_FILTER_2); gfx_ctx_set_filtering(2, g_settings.video.second_pass_smooth); set_delay = DELAY_LONG; } if(CTRL_START(state)) { - g_settings.video.second_pass_smooth = 1; + rarch_settings_change(S_DEF_HW_TEXTURE_FILTER_2); gfx_ctx_set_filtering(2, g_settings.video.second_pass_smooth); } break; case SETTING_SCALE_ENABLED: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state) || CTRL_CROSS(state)) { - g_console.fbo_enabled = !g_console.fbo_enabled; + rarch_settings_change(S_SCALE_ENABLED); gfx_ctx_set_fbo(g_console.fbo_enabled); - set_delay = DELAY_MEDIUM; - } if(CTRL_START(state)) { - g_console.fbo_enabled = true; - g_settings.video.fbo_scale_x = 2.0f; - g_settings.video.fbo_scale_y = 2.0f; + rarch_settings_default(S_DEF_SCALE_ENABLED); apply_scaling(FBO_DEINIT); apply_scaling(FBO_INIT); } @@ -1345,78 +1344,66 @@ static void producesettingentry(menu * menu_obj, uint64_t switchvalue) case SETTING_SCALE_FACTOR: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state)) { - if(g_console.fbo_enabled) - { - if((g_settings.video.fbo_scale_x > MIN_SCALING_FACTOR)) - { - g_settings.video.fbo_scale_x -= 1.0f; - g_settings.video.fbo_scale_y -= 1.0f; - apply_scaling(FBO_REINIT); - set_delay = DELAY_MEDIUM; - } - } + if(g_console.fbo_enabled) + { + bool should_decrement = g_settings.video.fbo_scale_x > MIN_SCALING_FACTOR; + if(should_decrement) + { + rarch_settings_change(S_SCALE_FACTOR_DECREMENT); + apply_scaling(FBO_REINIT); + set_delay = DELAY_MEDIUM; + } + } } if(CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state) || CTRL_CROSS(state)) { - if(g_console.fbo_enabled) - { - if((g_settings.video.fbo_scale_x < MAX_SCALING_FACTOR)) - { - g_settings.video.fbo_scale_x += 1.0f; - g_settings.video.fbo_scale_y += 1.0f; - apply_scaling(FBO_REINIT); - set_delay = DELAY_MEDIUM; - } - } + if(g_console.fbo_enabled) + { + bool should_increment = g_settings.video.fbo_scale_x < MAX_SCALING_FACTOR; + if(should_increment) + { + rarch_settings_change(S_SCALE_FACTOR_INCREMENT); + apply_scaling(FBO_REINIT); + set_delay = DELAY_MEDIUM; + } + } } if(CTRL_START(state)) { - g_settings.video.fbo_scale_x = 2.0f; - g_settings.video.fbo_scale_y = 2.0f; - apply_scaling(FBO_DEINIT); - apply_scaling(FBO_INIT); + rarch_settings_default(S_DEF_SCALE_FACTOR); + apply_scaling(FBO_DEINIT); + apply_scaling(FBO_INIT); } break; case SETTING_HW_OVERSCAN_AMOUNT: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_CROSS(state)) { - g_console.overscan_amount -= 0.01f; - g_console.overscan_enable = true; - - if(g_console.overscan_amount == 0.0f) - g_console.overscan_enable = false; - + rarch_settings_change(S_OVERSCAN_DECREMENT); gfx_ctx_set_overscan(); set_delay = DELAY_SMALLEST; } if(CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state) || CTRL_CROSS(state)) { - g_console.overscan_amount += 0.01f; - g_console.overscan_enable = true; - - if(g_console.overscan_amount == 0.0f) - g_console.overscan_enable = 0; - + rarch_settings_change(S_OVERSCAN_INCREMENT); gfx_ctx_set_overscan(); set_delay = DELAY_SMALLEST; } if(CTRL_START(state)) { - g_console.overscan_amount = 0.0f; - g_console.overscan_enable = false; + rarch_settings_default(S_DEF_OVERSCAN); gfx_ctx_set_overscan(); } break; case SETTING_THROTTLE_MODE: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state)) { - g_console.throttle_enable = !g_console.throttle_enable; + rarch_settings_change(S_THROTTLE); gfx_ctx_set_swap_interval(g_console.throttle_enable, true); set_delay = DELAY_MEDIUM; } if(CTRL_START(state)) { - g_console.throttle_enable = true; + rarch_settings_default(S_DEF_THROTTLE); gfx_ctx_set_swap_interval(g_console.throttle_enable, true); set_delay = DELAY_MEDIUM; } @@ -1424,54 +1411,54 @@ static void producesettingentry(menu * menu_obj, uint64_t switchvalue) case SETTING_TRIPLE_BUFFERING: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state)) { - g_console.triple_buffering_enable = !g_console.triple_buffering_enable; + rarch_settings_change(S_TRIPLE_BUFFERING); video_gl.restart(); set_delay = DELAY_MEDIUM; } if(CTRL_START(state)) { - if(!g_console.triple_buffering_enable) - { - g_console.triple_buffering_enable = true; - video_gl.restart(); - } + bool old_state = g_console.triple_buffering_enable; + rarch_settings_default(S_DEF_TRIPLE_BUFFERING); + + if(!old_state) + video_gl.restart(); } break; case SETTING_ENABLE_SCREENSHOTS: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state)) { #if(CELL_SDK_VERSION > 0x340000) - g_console.screenshots_enable = !g_console.screenshots_enable; - if(g_console.screenshots_enable) - { - cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_SCREENSHOT); - CellScreenShotSetParam screenshot_param = {0, 0, 0, 0}; + g_console.screenshots_enable = !g_console.screenshots_enable; + if(g_console.screenshots_enable) + { + cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_SCREENSHOT); + CellScreenShotSetParam screenshot_param = {0, 0, 0, 0}; - screenshot_param.photo_title = EMULATOR_NAME; - screenshot_param.game_title = EMULATOR_NAME; - cellScreenShotSetParameter (&screenshot_param); - cellScreenShotEnable(); - } - else - { - cellScreenShotDisable(); - cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_SCREENSHOT); - } + screenshot_param.photo_title = EMULATOR_NAME; + screenshot_param.game_title = EMULATOR_NAME; + cellScreenShotSetParameter (&screenshot_param); + cellScreenShotEnable(); + } + else + { + cellScreenShotDisable(); + cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_SCREENSHOT); + } - set_delay = DELAY_MEDIUM; + set_delay = DELAY_MEDIUM; #endif } if(CTRL_START(state)) { #if(CELL_SDK_VERSION > 0x340000) - g_console.screenshots_enable = true; + g_console.screenshots_enable = true; #endif } break; case SETTING_SAVE_SHADER_PRESET: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_RIGHT(state) | CTRL_LSTICK_RIGHT(state) || CTRL_CROSS(state)) { - rarch_filename_input_and_save(SHADER_PRESET_FILE); + rarch_filename_input_and_save(SHADER_PRESET_FILE); } break; case SETTING_APPLY_SHADER_PRESET_ON_STARTUP: @@ -1481,98 +1468,105 @@ static void producesettingentry(menu * menu_obj, uint64_t switchvalue) case SETTING_SOUND_MODE: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state)) { - if(g_console.sound_mode != SOUND_MODE_NORMAL) - { - g_console.sound_mode--; - set_delay = DELAY_MEDIUM; - } + if(g_console.sound_mode != SOUND_MODE_NORMAL) + { + g_console.sound_mode--; + set_delay = DELAY_MEDIUM; + } } if(CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state) || CTRL_CROSS(state)) { - if(g_console.sound_mode < SOUND_MODE_HEADSET) - { - g_console.sound_mode++; - set_delay = DELAY_MEDIUM; - } + if(g_console.sound_mode < SOUND_MODE_HEADSET) + { + g_console.sound_mode++; + set_delay = DELAY_MEDIUM; + } } if(CTRL_UP(state) || CTRL_LSTICK_UP(state) || CTRL_DOWN(state) || CTRL_LSTICK_DOWN(state)) { - if(g_console.sound_mode != SOUND_MODE_RSOUND) - { - rarch_console_rsound_stop(); - } - else - { - rarch_console_rsound_start(g_settings.audio.device); - } + if(g_console.sound_mode != SOUND_MODE_RSOUND) + rarch_console_rsound_stop(); + else + rarch_console_rsound_start(g_settings.audio.device); } if(CTRL_START(state)) { - g_console.sound_mode = SOUND_MODE_NORMAL; - rarch_console_rsound_stop(); - set_delay = DELAY_MEDIUM; + g_console.sound_mode = SOUND_MODE_NORMAL; + rarch_console_rsound_stop(); + set_delay = DELAY_MEDIUM; } break; case SETTING_RSOUND_SERVER_IP_ADDRESS: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_RIGHT(state) || CTRL_CROSS(state) | CTRL_LSTICK_RIGHT(state) ) { - oskutil_write_initial_message(&g_console.oskutil_handle, L"192.168.1.1"); - oskutil_write_message(&g_console.oskutil_handle, L"Enter IP address for the RSound Server."); - oskutil_start(&g_console.oskutil_handle); - while(OSK_IS_RUNNING(g_console.oskutil_handle)) - { - glClear(GL_COLOR_BUFFER_BIT); - gfx_ctx_swap_buffers(); + oskutil_write_initial_message(&g_console.oskutil_handle, L"192.168.1.1"); + oskutil_write_message(&g_console.oskutil_handle, L"Enter IP address for the RSound Server."); + oskutil_start(&g_console.oskutil_handle); + while(OSK_IS_RUNNING(g_console.oskutil_handle)) + { + glClear(GL_COLOR_BUFFER_BIT); + gfx_ctx_swap_buffers(); #ifdef HAVE_SYSUTILS - cellSysutilCheckCallback(); + cellSysutilCheckCallback(); #endif - } + } - if(g_console.oskutil_handle.text_can_be_fetched) - strlcpy(g_settings.audio.device, OUTPUT_TEXT_STRING(g_console.oskutil_handle), sizeof(g_settings.audio.device)); + if(g_console.oskutil_handle.text_can_be_fetched) + strlcpy(g_settings.audio.device, OUTPUT_TEXT_STRING(g_console.oskutil_handle), sizeof(g_settings.audio.device)); } if(CTRL_START(state)) - strlcpy(g_settings.audio.device, "0.0.0.0", sizeof(g_settings.audio.device)); + strlcpy(g_settings.audio.device, "0.0.0.0", sizeof(g_settings.audio.device)); break; case SETTING_DEFAULT_AUDIO_ALL: break; case SETTING_EMU_CURRENT_SAVE_STATE_SLOT: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_CROSS(state)) { - if(g_extern.state_slot != 0) - g_extern.state_slot--; - - set_delay = DELAY_MEDIUM; + rarch_settings_change(S_SAVESTATE_DECREMENT); + set_delay = DELAY_MEDIUM; } if(CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state) || CTRL_CROSS(state)) { - g_extern.state_slot++; - set_delay = DELAY_MEDIUM; + rarch_settings_change(S_SAVESTATE_INCREMENT); + set_delay = DELAY_MEDIUM; } if(CTRL_START(state)) - g_extern.state_slot = 0; + rarch_settings_default(S_DEF_SAVE_STATE); + break; + case SETTING_EMU_SHOW_INFO_MSG: + if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state)) + { + g_console.info_msg_enable = !g_console.info_msg_enable; + set_delay = DELAY_MEDIUM; + } + if(CTRL_START(state)) + { + g_console.info_msg_enable = true; + set_delay = DELAY_MEDIUM; + } break; case SETTING_EMU_REWIND_ENABLED: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state) || CTRL_CROSS(state)) { - g_settings.rewind_enable = !g_settings.rewind_enable; + rarch_settings_change(S_REWIND); - set_delay = DELAY_MEDIUM; + set_delay = DELAY_MEDIUM; + if(g_console.info_msg_enable) + rarch_settings_msg(S_MSG_RESTART_RARCH, S_DELAY_180); } if(CTRL_START(state)) - { - g_settings.rewind_enable = false; - } + g_settings.rewind_enable = false; break; case SETTING_RARCH_DEFAULT_EMU: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state) || CTRL_CROSS(state)) { - menuStackindex++; - menuStack[menuStackindex] = menu_filebrowser; - menuStack[menuStackindex].enum_id = LIBRETRO_CHOICE; - set_initial_dir_tmpbrowser = true; - set_delay = DELAY_LONG; + menuStackindex++; + menuStack[menuStackindex] = menu_filebrowser; + menuStack[menuStackindex].enum_id = LIBRETRO_CHOICE; + set_initial_dir_tmpbrowser = true; + set_libretro_core_as_launch = false; + set_delay = DELAY_LONG; } if(CTRL_START(state)) { @@ -1581,26 +1575,23 @@ static void producesettingentry(menu * menu_obj, uint64_t switchvalue) case SETTING_EMU_AUDIO_MUTE: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state) || CTRL_CROSS(state)) { - g_extern.audio_data.mute = !g_extern.audio_data.mute; - - set_delay = DELAY_MEDIUM; + g_extern.audio_data.mute = !g_extern.audio_data.mute; + set_delay = DELAY_MEDIUM; } if(CTRL_START(state)) - { - g_extern.audio_data.mute = false; - } + g_extern.audio_data.mute = false; break; case SETTING_ENABLE_CUSTOM_BGM: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state)) { #if(CELL_SDK_VERSION > 0x340000) - g_console.custom_bgm_enable = !g_console.custom_bgm_enable; - if(g_console.custom_bgm_enable) - cellSysutilEnableBgmPlayback(); - else - cellSysutilDisableBgmPlayback(); + g_console.custom_bgm_enable = !g_console.custom_bgm_enable; + if(g_console.custom_bgm_enable) + cellSysutilEnableBgmPlayback(); + else + cellSysutilDisableBgmPlayback(); - set_delay = DELAY_MEDIUM; + set_delay = DELAY_MEDIUM; #endif } if(CTRL_START(state)) @@ -1617,11 +1608,11 @@ static void producesettingentry(menu * menu_obj, uint64_t switchvalue) case SETTING_PATH_DEFAULT_ROM_DIRECTORY: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state) || CTRL_CROSS(state)) { - menuStackindex++; - menuStack[menuStackindex] = menu_filebrowser; - menuStack[menuStackindex].enum_id = PATH_DEFAULT_ROM_DIR_CHOICE; - set_initial_dir_tmpbrowser = true; - set_delay = DELAY_LONG; + menuStackindex++; + menuStack[menuStackindex] = menu_filebrowser; + menuStack[menuStackindex].enum_id = PATH_DEFAULT_ROM_DIR_CHOICE; + set_initial_dir_tmpbrowser = true; + set_delay = DELAY_LONG; } if(CTRL_START(state)) @@ -1630,113 +1621,111 @@ static void producesettingentry(menu * menu_obj, uint64_t switchvalue) case SETTING_PATH_SAVESTATES_DIRECTORY: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state) || CTRL_CROSS(state)) { - menuStackindex++; - menuStack[menuStackindex] = menu_filebrowser; - menuStack[menuStackindex].enum_id = PATH_SAVESTATES_DIR_CHOICE; - set_initial_dir_tmpbrowser = true; - set_delay = DELAY_LONG; + menuStackindex++; + menuStack[menuStackindex] = menu_filebrowser; + menuStack[menuStackindex].enum_id = PATH_SAVESTATES_DIR_CHOICE; + set_initial_dir_tmpbrowser = true; + set_delay = DELAY_LONG; } if(CTRL_START(state)) - strlcpy(g_console.default_savestate_dir, usrDirPath, sizeof(g_console.default_savestate_dir)); + strlcpy(g_console.default_savestate_dir, usrDirPath, sizeof(g_console.default_savestate_dir)); break; case SETTING_PATH_SRAM_DIRECTORY: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state) || CTRL_CROSS(state)) { - menuStackindex++; - menuStack[menuStackindex] = menu_filebrowser; - menuStack[menuStackindex].enum_id = PATH_SRAM_DIR_CHOICE; - set_initial_dir_tmpbrowser = true; - set_delay = DELAY_LONG; + menuStackindex++; + menuStack[menuStackindex] = menu_filebrowser; + menuStack[menuStackindex].enum_id = PATH_SRAM_DIR_CHOICE; + set_initial_dir_tmpbrowser = true; + set_delay = DELAY_LONG; } if(CTRL_START(state)) - strlcpy(g_console.default_sram_dir, "", sizeof(g_console.default_sram_dir)); + strlcpy(g_console.default_sram_dir, "", sizeof(g_console.default_sram_dir)); break; case SETTING_PATH_CHEATS: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state) || CTRL_CROSS(state)) { - menuStackindex++; - menuStack[menuStackindex] = menu_filebrowser; - menuStack[menuStackindex].enum_id = PATH_CHEATS_DIR_CHOICE; - set_initial_dir_tmpbrowser = true; - set_delay = DELAY_LONG; + menuStackindex++; + menuStack[menuStackindex] = menu_filebrowser; + menuStack[menuStackindex].enum_id = PATH_CHEATS_DIR_CHOICE; + set_initial_dir_tmpbrowser = true; + set_delay = DELAY_LONG; } if(CTRL_START(state)) - strlcpy(g_settings.cheat_database, usrDirPath, sizeof(g_settings.cheat_database)); + strlcpy(g_settings.cheat_database, usrDirPath, sizeof(g_settings.cheat_database)); break; case SETTING_ENABLE_SRAM_PATH: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state)) { - g_console.default_sram_dir_enable = !g_console.default_sram_dir_enable; - menu_reinit_settings(); - set_delay = DELAY_MEDIUM; + g_console.default_sram_dir_enable = !g_console.default_sram_dir_enable; + menu_reinit_settings(); + set_delay = DELAY_MEDIUM; } if(CTRL_START(state)) { - g_console.default_sram_dir_enable = true; - menu_reinit_settings(); + g_console.default_sram_dir_enable = true; + menu_reinit_settings(); } break; case SETTING_ENABLE_STATE_PATH: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state)) { - g_console.default_savestate_dir_enable = !g_console.default_savestate_dir_enable; - menu_reinit_settings(); - set_delay = DELAY_MEDIUM; + g_console.default_savestate_dir_enable = !g_console.default_savestate_dir_enable; + menu_reinit_settings(); + set_delay = DELAY_MEDIUM; } if(CTRL_START(state)) { - g_console.default_savestate_dir_enable = true; - menu_reinit_settings(); + g_console.default_savestate_dir_enable = true; + menu_reinit_settings(); } break; case SETTING_PATH_DEFAULT_ALL: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state) || CTRL_CROSS(state) || CTRL_START(state)) { - strlcpy(g_console.default_rom_startup_dir, "/", sizeof(g_console.default_rom_startup_dir)); - strlcpy(g_console.default_savestate_dir, usrDirPath, sizeof(g_console.default_savestate_dir)); - strlcpy(g_settings.cheat_database, usrDirPath, sizeof(g_settings.cheat_database)); - strlcpy(g_console.default_sram_dir, "", sizeof(g_console.default_sram_dir)); + strlcpy(g_console.default_rom_startup_dir, "/", sizeof(g_console.default_rom_startup_dir)); + strlcpy(g_console.default_savestate_dir, usrDirPath, sizeof(g_console.default_savestate_dir)); + strlcpy(g_settings.cheat_database, usrDirPath, sizeof(g_settings.cheat_database)); + strlcpy(g_console.default_sram_dir, "", sizeof(g_console.default_sram_dir)); - menu_reinit_settings(); + menu_reinit_settings(); } break; case SETTING_CONTROLS_SCHEME: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_CROSS(state) | CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state) || CTRL_CROSS(state)) { - menuStackindex++; - menuStack[menuStackindex] = menu_filebrowser; - menuStack[menuStackindex].enum_id = INPUT_PRESET_CHOICE; - set_initial_dir_tmpbrowser = true; - set_delay = DELAY_LONG; + menuStackindex++; + menuStack[menuStackindex] = menu_filebrowser; + menuStack[menuStackindex].enum_id = INPUT_PRESET_CHOICE; + set_initial_dir_tmpbrowser = true; + set_delay = DELAY_LONG; } if(CTRL_START(state)) - { - menu_reinit_settings(); - } + menu_reinit_settings(); break; case SETTING_CONTROLS_NUMBER: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_CROSS(state)) { - if(currently_selected_controller_menu != 0) - currently_selected_controller_menu--; - menu_reinit_settings(); - set_delay = DELAY_MEDIUM; + if(currently_selected_controller_menu != 0) + currently_selected_controller_menu--; + menu_reinit_settings(); + set_delay = DELAY_MEDIUM; } if(CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state) || CTRL_CROSS(state)) { - if(currently_selected_controller_menu < 6) - currently_selected_controller_menu++; - menu_reinit_settings(); - set_delay = DELAY_MEDIUM; + if(currently_selected_controller_menu < 6) + currently_selected_controller_menu++; + menu_reinit_settings(); + set_delay = DELAY_MEDIUM; } if(CTRL_START(state)) - currently_selected_controller_menu = 0; + currently_selected_controller_menu = 0; break; case SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_UP: set_keybind_digital(state, RETRO_DEVICE_ID_JOYPAD_UP); @@ -1785,15 +1774,13 @@ static void producesettingentry(menu * menu_obj, uint64_t switchvalue) break; case SETTING_CONTROLS_SAVE_CUSTOM_CONTROLS: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state) || CTRL_CROSS(state) || CTRL_START(state)) - { - rarch_filename_input_and_save(INPUT_PRESET_FILE); - } + rarch_filename_input_and_save(INPUT_PRESET_FILE); break; case SETTING_CONTROLS_DEFAULT_ALL: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state) || CTRL_CROSS(state) || CTRL_START(state)) { - rarch_input_set_default_keybinds(currently_selected_controller_menu); - menu_reinit_settings(); + rarch_input_set_default_keybinds(currently_selected_controller_menu); + menu_reinit_settings(); } break; } @@ -1862,7 +1849,7 @@ static void select_setting(menu * menu_obj) if (menu_obj->items[menu_obj->selected].page != menu_obj->page) menu_obj->page = menu_obj->items[menu_obj->selected].page; - set_delay = DELAY_MEDIUM; + set_delay = DELAY_SMALL; } /* up to previous setting */ @@ -1877,14 +1864,14 @@ static void select_setting(menu * menu_obj) if (menu_obj->items[menu_obj->selected].page != menu_obj->page) menu_obj->page = menu_obj->items[menu_obj->selected].page; - set_delay = DELAY_MEDIUM; + set_delay = DELAY_SMALL; } producesettingentry(menu_obj, menu_obj->selected); } display_menubar(menu_obj->enum_id); - cellDbgFontDraw(); + gl_render_msg_post(gl); for ( i = menu_obj->first_setting; i < menu_obj->max_settings; i++) { @@ -1892,7 +1879,7 @@ static void select_setting(menu * menu_obj) { cellDbgFontPuts(menu_obj->items[i].text_xpos, menu_obj->items[i].text_ypos, FONT_SIZE, menu_obj->selected == menu_obj->items[i].enum_id ? YELLOW : menu_obj->items[i].item_color, menu_obj->items[i].text); cellDbgFontPuts(0.5f, menu_obj->items[i].text_ypos, FONT_SIZE, menu_obj->items[i].text_color, menu_obj->items[i].setting_text); - cellDbgFontDraw(); + gl_render_msg_post(gl); } } @@ -1900,7 +1887,7 @@ static void select_setting(menu * menu_obj) cellDbgFontPuts(0.09f, 0.91f, FONT_SIZE, YELLOW, "UP/DOWN - select L3+R3 - resume game X/LEFT/RIGHT - change"); cellDbgFontPuts(0.09f, 0.95f, FONT_SIZE, YELLOW, "START - default L1/CIRCLE - go back R1 - go forward"); - cellDbgFontDraw(); + gl_render_msg_post(gl); old_state = state; } @@ -1946,7 +1933,7 @@ static void select_rom(void) } else if (FILEBROWSER_IS_CURRENT_A_FILE(browser)) { - char rom_path_temp[MAX_PATH_LENGTH]; + char rom_path_temp[PATH_MAX]; struct retro_system_info info; retro_get_system_info(&info); bool block_zip_extract = info.block_extract; @@ -1957,10 +1944,8 @@ static void select_rom(void) rarch_extract_zipfile(rom_path_temp); else { - g_console.menu_enable = false; snprintf(g_console.rom_path, sizeof(g_console.rom_path), "%s/%s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(browser), FILEBROWSER_GET_CURRENT_FILENAME(browser)); - g_console.initialize_rarch_enable = 1; - g_console.mode_switch = MODE_EMULATION; + rarch_settings_change(S_START_RARCH); } } } @@ -1989,7 +1974,7 @@ static void select_rom(void) "PATH: %s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(browser)); cellDbgFontPuts (0.09f, 0.93f, FONT_SIZE, YELLOW, "L3 + R3 - resume game SELECT - Settings screen"); - cellDbgFontDraw(); + gl_render_msg_post(gl); browser_render(&browser); old_state = state; @@ -1997,17 +1982,9 @@ static void select_rom(void) #define MENU_ITEM_SELECTED(index) (menuitem_colors[index]) -static void return_to_game (void) -{ - g_console.frame_advance_enable = false; - g_console.ingame_menu_item = 0; - g_console.menu_enable = false; - g_console.mode_switch = MODE_EMULATION; -} - static void ingame_menu(uint32_t menu_id) { - char comment[256], msg_temp[256]; + char comment[256]; static uint32_t menuitem_colors[MENU_ITEM_LAST]; uint64_t state, stuck_in_loop; static uint64_t blocking; @@ -2023,7 +2000,6 @@ static void ingame_menu(uint32_t menu_id) menuitem_colors[g_console.ingame_menu_item] = RED; - state = cell_pad_input_poll_device(0); stuck_in_loop = 1; blocking = 0; @@ -2033,7 +2009,7 @@ static void ingame_menu(uint32_t menu_id) set_delay = DELAY_NONE; if(CTRL_CIRCLE(state)) - return_to_game(); + rarch_settings_change(S_RETURN_TO_GAME); switch(g_console.ingame_menu_item) { @@ -2041,18 +2017,18 @@ static void ingame_menu(uint32_t menu_id) if(CTRL_CROSS(state)) { rarch_load_state(); - return_to_game(); + rarch_settings_change(S_RETURN_TO_GAME); } if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state)) { rarch_state_slot_decrease(); - set_delay = DELAY_LONG; + set_delay = DELAY_MEDIUM; blocking = 0; } if(CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state)) { rarch_state_slot_increase(); - set_delay = DELAY_LONG; + set_delay = DELAY_MEDIUM; blocking = 0; } @@ -2062,18 +2038,18 @@ static void ingame_menu(uint32_t menu_id) if(CTRL_CROSS(state)) { rarch_save_state(); - return_to_game(); + rarch_settings_change(S_RETURN_TO_GAME); } if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state)) { rarch_state_slot_decrease(); - set_delay = DELAY_LONG; + set_delay = DELAY_MEDIUM; blocking = 0; } if(CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state)) { rarch_state_slot_increase(); - set_delay = DELAY_LONG; + set_delay = DELAY_MEDIUM; blocking = 0; } @@ -2082,27 +2058,19 @@ static void ingame_menu(uint32_t menu_id) case MENU_ITEM_KEEP_ASPECT_RATIO: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state)) { - if(g_console.aspect_ratio_index > 0) - { - g_console.aspect_ratio_index--; - gfx_ctx_set_aspect_ratio(NULL, g_console.aspect_ratio_index); - set_delay = DELAY_LONG; - } + rarch_settings_change(S_ASPECT_RATIO_DECREMENT); + gfx_ctx_set_aspect_ratio(NULL, g_console.aspect_ratio_index); + set_delay = DELAY_MEDIUM; } if(CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state)) { - g_console.aspect_ratio_index++; - if(g_console.aspect_ratio_index < ASPECT_RATIO_END) - { - gfx_ctx_set_aspect_ratio(NULL, g_console.aspect_ratio_index); - set_delay = DELAY_LONG; - } - else - g_console.aspect_ratio_index = ASPECT_RATIO_END-1; + rarch_settings_change(S_ASPECT_RATIO_INCREMENT); + gfx_ctx_set_aspect_ratio(NULL, g_console.aspect_ratio_index); + set_delay = DELAY_MEDIUM; } if(CTRL_START(state)) { - g_console.aspect_ratio_index = ASPECT_RATIO_4_3; + rarch_settings_default(S_DEF_ASPECT_RATIO); gfx_ctx_set_aspect_ratio(NULL, g_console.aspect_ratio_index); } strlcpy(comment, "Press LEFT or RIGHT to change the [Aspect Ratio].\nPress START to reset back to default values.", sizeof(comment)); @@ -2110,29 +2078,19 @@ static void ingame_menu(uint32_t menu_id) case MENU_ITEM_OVERSCAN_AMOUNT: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_CROSS(state) || CTRL_LSTICK_LEFT(state)) { - g_console.overscan_amount -= 0.01f; - g_console.overscan_enable = true; - - if(g_console.overscan_amount == 0.00f) - g_console.overscan_enable = false; - + rarch_settings_change(S_OVERSCAN_DECREMENT); gfx_ctx_set_overscan(); set_delay = DELAY_SMALLEST; } if(CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state) || CTRL_CROSS(state) || CTRL_LSTICK_RIGHT(state)) { - g_console.overscan_amount += 0.01f; - g_console.overscan_enable = true; - if(g_console.overscan_amount == 0.0f) - g_console.overscan_amount = false; - + rarch_settings_change(S_OVERSCAN_INCREMENT); gfx_ctx_set_overscan(); set_delay = DELAY_SMALLEST; } if(CTRL_START(state)) { - g_console.overscan_amount = 0.0f; - g_console.overscan_enable = false; + rarch_settings_default(S_DEF_OVERSCAN); gfx_ctx_set_overscan(); } strlcpy(comment, "Press LEFT or RIGHT to change the [Overscan] settings.\nPress START to reset back to default values.", sizeof(comment)); @@ -2140,27 +2098,21 @@ static void ingame_menu(uint32_t menu_id) case MENU_ITEM_ORIENTATION: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state) || CTRL_CROSS(state) || CTRL_LSTICK_LEFT(state)) { - if(g_console.screen_orientation > ORIENTATION_NORMAL) - { - g_console.screen_orientation--; - video_gl.set_rotation(NULL, g_console.screen_orientation); - set_delay = DELAY_LONG; - } + rarch_settings_change(S_ROTATION_DECREMENT); + video_gl.set_rotation(NULL, g_console.screen_orientation); + set_delay = DELAY_MEDIUM; } if(CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state) || CTRL_CROSS(state) || CTRL_LSTICK_RIGHT(state)) { - if((g_console.screen_orientation+1) < ORIENTATION_END) - { - g_console.screen_orientation++; - video_gl.set_rotation(NULL, g_console.screen_orientation); - set_delay = DELAY_LONG; - } + rarch_settings_change(S_ROTATION_INCREMENT); + video_gl.set_rotation(NULL, g_console.screen_orientation); + set_delay = DELAY_MEDIUM; } if(CTRL_START(state)) { - g_console.screen_orientation = ORIENTATION_NORMAL; + rarch_settings_default(S_DEF_ROTATION); video_gl.set_rotation(NULL, g_console.screen_orientation); } strlcpy(comment, "Press LEFT or RIGHT to change the [Orientation] settings.\nPress START to reset back to default values.", sizeof(comment)); @@ -2172,10 +2124,9 @@ static void ingame_menu(uint32_t menu_id) { if((g_settings.video.fbo_scale_x > MIN_SCALING_FACTOR)) { - g_settings.video.fbo_scale_x -= 1.0f; - g_settings.video.fbo_scale_y -= 1.0f; + rarch_settings_change(S_SCALE_FACTOR_DECREMENT); apply_scaling(FBO_REINIT); - set_delay = DELAY_LONG; + set_delay = DELAY_MEDIUM; } } } @@ -2185,17 +2136,15 @@ static void ingame_menu(uint32_t menu_id) { if((g_settings.video.fbo_scale_x < MAX_SCALING_FACTOR)) { - g_settings.video.fbo_scale_x += 1.0f; - g_settings.video.fbo_scale_y += 1.0f; + rarch_settings_change(S_SCALE_FACTOR_INCREMENT); apply_scaling(FBO_REINIT); - set_delay = DELAY_LONG; + set_delay = DELAY_MEDIUM; } } } if(CTRL_START(state)) { - g_settings.video.fbo_scale_x = 2.0f; - g_settings.video.fbo_scale_y = 2.0f; + rarch_settings_default(S_DEF_SCALE_FACTOR); apply_scaling(FBO_REINIT); } strlcpy(comment, "Press LEFT or RIGHT to change the [Scaling] settings.\nPress START to reset back to default values.", sizeof(comment)); @@ -2203,10 +2152,8 @@ static void ingame_menu(uint32_t menu_id) case MENU_ITEM_FRAME_ADVANCE: if(CTRL_CROSS(state) || CTRL_R2(state) || CTRL_L2(state)) { - g_console.frame_advance_enable = true; + rarch_settings_change(S_FRAME_ADVANCE); g_console.ingame_menu_item = MENU_ITEM_FRAME_ADVANCE; - g_console.menu_enable = false; - g_console.mode_switch = MODE_EMULATION; } strlcpy(comment, "Press 'CROSS', 'L2' or 'R2' button to step one frame. Pressing the button\nrapidly will advance the frame more slowly.", sizeof(comment)); break; @@ -2229,13 +2176,9 @@ static void ingame_menu(uint32_t menu_id) rarch_render_cached_frame(); if(CTRL_SQUARE(state)) - { gl->menu_render = false; - } else - { gl->menu_render = true; - } if(CTRL_LSTICK_LEFT(state) || CTRL_LEFT(state)) g_console.viewports.custom_vp.x -= 1; @@ -2278,7 +2221,7 @@ static void ingame_menu(uint32_t menu_id) cellDbgFontPuts (0.09f, 0.05f, FONT_SIZE, RED, "QUICK MENU"); cellDbgFontPrintf (0.3f, 0.05f, 0.82f, WHITE, "Libretro core: %s", id); - cellDbgFontPrintf (0.9f, 0.09f, 0.82f, WHITE, "v%s", EMULATOR_VERSION); + cellDbgFontPrintf (0.8f, 0.09f, 0.82f, WHITE, "v%s", EMULATOR_VERSION); cellDbgFontPrintf(x_position, 0.14f, 1.4f, WHITE, "Resize Mode"); cellDbgFontPrintf(x_position, ypos, font_size, GREEN, "Viewport X: #%d", g_console.viewports.custom_vp.x); @@ -2293,7 +2236,7 @@ static void ingame_menu(uint32_t menu_id) cellDbgFontPrintf (0.09f, 0.46f, font_size, LIGHTBLUE, "LEFT or LSTICK UP"); cellDbgFontPrintf (0.5f, 0.46f, font_size, LIGHTBLUE, "- Decrease Viewport X"); - cellDbgFontDraw(); + gl_render_msg_post(gl); cellDbgFontPrintf (0.09f, 0.48f, font_size, LIGHTBLUE, "RIGHT or LSTICK RIGHT"); cellDbgFontPrintf (0.5f, 0.48f, font_size, LIGHTBLUE, "- Increase Viewport X"); @@ -2301,7 +2244,7 @@ static void ingame_menu(uint32_t menu_id) cellDbgFontPrintf (0.09f, 0.50f, font_size, LIGHTBLUE, "UP or LSTICK UP"); cellDbgFontPrintf (0.5f, 0.50f, font_size, LIGHTBLUE, "- Increase Viewport Y"); - cellDbgFontDraw(); + gl_render_msg_post(gl); cellDbgFontPrintf (0.09f, 0.52f, font_size, LIGHTBLUE, "DOWN or LSTICK DOWN"); cellDbgFontPrintf (0.5f, 0.52f, font_size, LIGHTBLUE, "- Decrease Viewport Y"); @@ -2309,7 +2252,7 @@ static void ingame_menu(uint32_t menu_id) cellDbgFontPrintf (0.09f, 0.54f, font_size, LIGHTBLUE, "L1 or RSTICK LEFT"); cellDbgFontPrintf (0.5f, 0.54f, font_size, LIGHTBLUE, "- Decrease Viewport Width"); - cellDbgFontDraw(); + gl_render_msg_post(gl); cellDbgFontPrintf (0.09f, 0.56f, font_size, LIGHTBLUE, "R1 or RSTICK RIGHT"); cellDbgFontPrintf (0.5f, 0.56f, font_size, LIGHTBLUE, "- Increase Viewport Width"); @@ -2317,7 +2260,7 @@ static void ingame_menu(uint32_t menu_id) cellDbgFontPrintf (0.09f, 0.58f, font_size, LIGHTBLUE, "L2 or RSTICK UP"); cellDbgFontPrintf (0.5f, 0.58f, font_size, LIGHTBLUE, "- Increase Viewport Height"); - cellDbgFontDraw(); + gl_render_msg_post(gl); cellDbgFontPrintf (0.09f, 0.60f, font_size, LIGHTBLUE, "R2 or RSTICK DOWN"); cellDbgFontPrintf (0.5f, 0.60f, font_size, LIGHTBLUE, "- Decrease Viewport Height"); @@ -2331,10 +2274,10 @@ static void ingame_menu(uint32_t menu_id) cellDbgFontPrintf (0.09f, 0.70f, font_size, LIGHTBLUE, "CIRCLE"); cellDbgFontPrintf (0.5f, 0.70f, font_size, LIGHTBLUE, "- Return to Ingame Menu"); - cellDbgFontDraw(); + gl_render_msg_post(gl); cellDbgFontPrintf (0.09f, 0.83f, 0.91f, LIGHTBLUE, "Allows you to resize the screen by moving around the two analog sticks.\nPress TRIANGLE to reset to default values, and CIRCLE to go back to the menu."); - cellDbgFontDraw(); + gl_render_msg_post(gl); } gfx_ctx_swap_buffers(); #ifdef HAVE_SYSUTILS @@ -2353,6 +2296,7 @@ static void ingame_menu(uint32_t menu_id) { while(stuck_in_loop && g_console.ingame_menu_enable) { + gl->menu_render = false; state = cell_pad_input_poll_device(0); if(CTRL_CIRCLE(state)) { @@ -2367,20 +2311,21 @@ static void ingame_menu(uint32_t menu_id) cellSysutilCheckCallback(); #endif } + gl->menu_render = true; } strlcpy(comment, "Allows you to take a screenshot without any text clutter.\nPress CIRCLE to go back to the in-game menu while in 'Screenshot Mode'.", sizeof(comment)); break; case MENU_ITEM_RETURN_TO_GAME: if(CTRL_CROSS(state)) - return_to_game(); + rarch_settings_change(S_RETURN_TO_GAME); strlcpy(comment, "Press 'CROSS' to return back to the game.", sizeof(comment)); break; case MENU_ITEM_RESET: if(CTRL_CROSS(state)) { - return_to_game(); + rarch_settings_change(S_RETURN_TO_GAME); rarch_game_reset(); } strlcpy(comment, "Press 'CROSS' to reset the game.", sizeof(comment)); @@ -2388,10 +2333,8 @@ static void ingame_menu(uint32_t menu_id) case MENU_ITEM_RETURN_TO_MENU: if(CTRL_CROSS(state)) { - g_console.menu_enable = false; - g_console.ingame_menu_item = 0; - g_console.mode_switch = MODE_MENU; - set_delay = DELAY_LONG; + rarch_settings_change(S_RETURN_TO_MENU); + set_delay = DELAY_MEDIUM; } strlcpy(comment, "Press 'CROSS' to return to the ROM Browser menu.", sizeof(comment)); break; @@ -2401,29 +2344,27 @@ static void ingame_menu(uint32_t menu_id) menuStackindex++; menuStack[menuStackindex] = menu_filebrowser; menuStack[menuStackindex].enum_id = LIBRETRO_CHOICE; + set_libretro_core_as_launch = true; set_initial_dir_tmpbrowser = true; set_delay = DELAY_LONG; } strlcpy(comment, "Press 'CROSS' to choose a different emulator core.", sizeof(comment)); break; +#ifdef HAVE_MULTIMAN case MENU_ITEM_RETURN_TO_MULTIMAN: if(CTRL_CROSS(state) && path_file_exists(MULTIMAN_EXECUTABLE)) { strlcpy(g_console.launch_app_on_exit, MULTIMAN_EXECUTABLE, sizeof(g_console.launch_app_on_exit)); - g_console.return_to_launcher = true; - g_console.menu_enable = false; - g_console.mode_switch = MODE_EXIT; + rarch_settings_change(S_RETURN_TO_DASHBOARD); } strlcpy(comment, "Press 'CROSS' to quit the emulator and return to multiMAN.", sizeof(comment)); break; - case MENU_ITEM_RETURN_TO_XMB: +#endif + case MENU_ITEM_RETURN_TO_DASHBOARD: if(CTRL_CROSS(state)) - { - g_console.menu_enable = false; - g_console.mode_switch = MODE_EXIT; - } + rarch_settings_change(S_RETURN_TO_DASHBOARD); strlcpy(comment, "Press 'CROSS' to quit the emulator and return to the XMB.", sizeof(comment)); break; @@ -2434,7 +2375,7 @@ static void ingame_menu(uint32_t menu_id) if(g_console.ingame_menu_item > 0) { g_console.ingame_menu_item--; - set_delay = DELAY_MEDIUM; + set_delay = DELAY_SMALL; } } @@ -2443,49 +2384,36 @@ static void ingame_menu(uint32_t menu_id) if(g_console.ingame_menu_item < (MENU_ITEM_LAST-1)) { g_console.ingame_menu_item++; - set_delay = DELAY_MEDIUM; + set_delay = DELAY_SMALL; } } if(CTRL_L3(state) && CTRL_R3(state)) - { - return_to_game(); - } + rarch_settings_change(S_RETURN_TO_GAME); } - switch(g_console.screen_orientation) - { - case ORIENTATION_NORMAL: - snprintf(msg_temp, sizeof(msg_temp), "Normal"); - break; - case ORIENTATION_VERTICAL: - snprintf(msg_temp, sizeof(msg_temp), "Vertical"); - break; - case ORIENTATION_FLIPPED: - snprintf(msg_temp, sizeof(msg_temp), "Flipped"); - break; - case ORIENTATION_FLIPPED_ROTATED: - snprintf(msg_temp, sizeof(msg_temp), "Flipped Rotated"); - break; - } - cellDbgFontPrintf(x_position, 0.14f, 1.4f, WHITE, "Quick Menu"); - cellDbgFontPrintf(x_position, ypos, font_size, MENU_ITEM_SELECTED(MENU_ITEM_LOAD_STATE), "Load State #%d", g_extern.state_slot); + rarch_settings_create_menu_item_label(strw_buffer, S_LBL_LOAD_STATE_SLOT, sizeof(strw_buffer)); + cellDbgFontPrintf(x_position, ypos, font_size, MENU_ITEM_SELECTED(MENU_ITEM_LOAD_STATE), strw_buffer); - cellDbgFontPrintf(x_position, ypos+(ypos_increment*MENU_ITEM_SAVE_STATE), font_size, MENU_ITEM_SELECTED(MENU_ITEM_SAVE_STATE), "Save State #%d", g_extern.state_slot); - cellDbgFontDraw(); + rarch_settings_create_menu_item_label(strw_buffer, S_LBL_SAVE_STATE_SLOT, sizeof(strw_buffer)); + cellDbgFontPrintf(x_position, ypos+(ypos_increment*MENU_ITEM_SAVE_STATE), font_size, MENU_ITEM_SELECTED(MENU_ITEM_SAVE_STATE), strw_buffer); + gl_render_msg_post(gl); - cellDbgFontPrintf(x_position, (ypos+(ypos_increment*MENU_ITEM_KEEP_ASPECT_RATIO)), font_size, MENU_ITEM_SELECTED(MENU_ITEM_KEEP_ASPECT_RATIO), "Aspect Ratio: %s", aspectratio_lut[g_console.aspect_ratio_index].name); + rarch_settings_create_menu_item_label(strw_buffer, S_LBL_ASPECT_RATIO, sizeof(strw_buffer)); + cellDbgFontPrintf(x_position, (ypos+(ypos_increment*MENU_ITEM_KEEP_ASPECT_RATIO)), font_size, MENU_ITEM_SELECTED(MENU_ITEM_KEEP_ASPECT_RATIO), strw_buffer); cellDbgFontPrintf(x_position, (ypos+(ypos_increment*MENU_ITEM_OVERSCAN_AMOUNT)), font_size, MENU_ITEM_SELECTED(MENU_ITEM_OVERSCAN_AMOUNT), "Overscan: %f", g_console.overscan_amount); - cellDbgFontPrintf (x_position, (ypos+(ypos_increment*MENU_ITEM_ORIENTATION)), font_size, MENU_ITEM_SELECTED(MENU_ITEM_ORIENTATION), "Orientation: %s", msg_temp); - cellDbgFontDraw(); + rarch_settings_create_menu_item_label(strw_buffer, S_LBL_ROTATION, sizeof(strw_buffer)); + cellDbgFontPrintf (x_position, (ypos+(ypos_increment*MENU_ITEM_ORIENTATION)), font_size, MENU_ITEM_SELECTED(MENU_ITEM_ORIENTATION), strw_buffer); + gl_render_msg_post(gl); - cellDbgFontPrintf (x_position, (ypos+(ypos_increment*MENU_ITEM_SCALE_FACTOR)), font_size, MENU_ITEM_SELECTED(MENU_ITEM_SCALE_FACTOR), "Scale Factor: %d", (int)(g_settings.video.fbo_scale_x)); - cellDbgFontDraw(); + rarch_settings_create_menu_item_label(strw_buffer, S_LBL_SCALE_FACTOR, sizeof(strw_buffer)); + cellDbgFontPrintf (x_position, (ypos+(ypos_increment*MENU_ITEM_SCALE_FACTOR)), font_size, MENU_ITEM_SELECTED(MENU_ITEM_SCALE_FACTOR), strw_buffer); + gl_render_msg_post(gl); cellDbgFontPrintf(x_position, (ypos+(ypos_increment*MENU_ITEM_RESIZE_MODE)), font_size, MENU_ITEM_SELECTED(MENU_ITEM_RESIZE_MODE), "Resize Mode"); @@ -2493,23 +2421,25 @@ static void ingame_menu(uint32_t menu_id) cellDbgFontPuts(x_position, (ypos+(ypos_increment*MENU_ITEM_SCREENSHOT_MODE)), font_size, MENU_ITEM_SELECTED(MENU_ITEM_SCREENSHOT_MODE), "Screenshot Mode"); - cellDbgFontDraw(); + gl_render_msg_post(gl); cellDbgFontPuts(x_position, (ypos+(ypos_increment*MENU_ITEM_RESET)), font_size, MENU_ITEM_SELECTED(MENU_ITEM_RESET), "Reset"); cellDbgFontPuts(x_position, (ypos+(ypos_increment*MENU_ITEM_RETURN_TO_GAME)), font_size, MENU_ITEM_SELECTED(MENU_ITEM_RETURN_TO_GAME), "Return to Game"); - cellDbgFontDraw(); + gl_render_msg_post(gl); cellDbgFontPuts(x_position, (ypos+(ypos_increment*MENU_ITEM_RETURN_TO_MENU)), font_size, MENU_ITEM_SELECTED(MENU_ITEM_RETURN_TO_MENU), "Return to Menu"); - cellDbgFontDraw(); + gl_render_msg_post(gl); cellDbgFontPuts(x_position, (ypos+(ypos_increment*MENU_ITEM_CHANGE_LIBRETRO)), font_size, MENU_ITEM_SELECTED(MENU_ITEM_CHANGE_LIBRETRO), "Change libretro core"); - cellDbgFontDraw(); + gl_render_msg_post(gl); +#ifdef HAVE_MULTIMAN cellDbgFontPuts(x_position, (ypos+(ypos_increment*MENU_ITEM_RETURN_TO_MULTIMAN)), font_size, MENU_ITEM_SELECTED(MENU_ITEM_RETURN_TO_MULTIMAN), "Return to multiMAN"); +#endif - cellDbgFontPuts(x_position, (ypos+(ypos_increment*MENU_ITEM_RETURN_TO_XMB)), font_size, MENU_ITEM_SELECTED(MENU_ITEM_RETURN_TO_XMB), "Return to XMB"); - cellDbgFontDraw(); + cellDbgFontPuts(x_position, (ypos+(ypos_increment*MENU_ITEM_RETURN_TO_DASHBOARD)), font_size, MENU_ITEM_SELECTED(MENU_ITEM_RETURN_TO_DASHBOARD), "Return to XMB"); + gl_render_msg_post(gl); struct retro_system_info info; retro_get_system_info(&info); @@ -2518,11 +2448,9 @@ static void ingame_menu(uint32_t menu_id) cellDbgFontPuts(0.09f, 0.05f, FONT_SIZE, RED, "QUICK MENU"); cellDbgFontPrintf (0.3f, 0.05f, 0.82f, WHITE, "Libretro core: %s", id); cellDbgFontPrintf (0.8f, 0.09f, 0.82f, WHITE, "v%s", EMULATOR_VERSION); - cellDbgFontDraw(); - cellDbgFontPrintf (0.05f, 0.90f, 1.10f, WHITE, special_action_msg); - cellDbgFontDraw(); + gl_render_msg_post(gl); cellDbgFontPrintf(0.09f, 0.83f, 0.91f, LIGHTBLUE, comment); - cellDbgFontDraw(); + gl_render_msg_post(gl); old_state = state; } @@ -2590,7 +2518,7 @@ void menu_loop(void) break; case INGAME_MENU: if(g_console.ingame_menu_enable) - ingame_menu(menuStack[menuStackindex].enum_id); + ingame_menu(menuStack[menuStackindex].enum_id); break; } @@ -2627,6 +2555,18 @@ void menu_loop(void) SET_TIMER_EXPIRATION(gl, 30); } + const char * message = msg_queue_pull(g_extern.msg_queue); + + if (message && g_console.info_msg_enable) + { + if(IS_TIMER_EXPIRED(gl)) + { + SET_TIMER_EXPIRATION(gl, 30); + } + cellDbgFontPrintf(g_settings.video.msg_pos_x, 0.75f, 1.05f, WHITE, message); + gl_render_msg_post(gl); + } + gfx_ctx_swap_buffers(); #ifdef HAVE_SYSUTILS cellSysutilCheckCallback(); diff --git a/ps3/menu.h b/ps3/menu.h index 0a1ebbc96f..5034605575 100644 --- a/ps3/menu.h +++ b/ps3/menu.h @@ -102,6 +102,7 @@ enum SETTING_ENABLE_CUSTOM_BGM, SETTING_DEFAULT_AUDIO_ALL, SETTING_EMU_CURRENT_SAVE_STATE_SLOT, + SETTING_EMU_SHOW_INFO_MSG, SETTING_RARCH_DEFAULT_EMU, SETTING_EMU_DEFAULT_ALL, SETTING_EMU_REWIND_ENABLED, diff --git a/ps3/ps3_audio.c b/ps3/ps3_audio.c index e5c8f9005b..95152daecf 100644 --- a/ps3/ps3_audio.c +++ b/ps3/ps3_audio.c @@ -90,9 +90,9 @@ static void *ps3_audio_init(const char *device, unsigned rate, unsigned latency) params.nChannel = AUDIO_CHANNELS; params.nBlock = AUDIO_BLOCKS; if(g_console.sound_mode == SOUND_MODE_HEADSET) - params.attr = CELL_AUDIO_PORTATTR_OUT_SECONDARY; + params.attr = CELL_AUDIO_PORTATTR_OUT_SECONDARY; else - params.attr = 0; + params.attr = 0; if (cellAudioPortOpen(¶ms, &data->audio_port) != CELL_OK) { diff --git a/ps3/ps3_input.c b/ps3/ps3_input.c index f92dd7fd8d..546d8c7312 100644 --- a/ps3/ps3_input.c +++ b/ps3/ps3_input.c @@ -244,7 +244,7 @@ void oskutil_unload(oskutil_params *params) static void ps3_free_input(void *data) { (void)data; - cellPadEnd(); + //cellPadEnd(); } static void* ps3_input_initialize(void) diff --git a/ps3/ps3_video_psgl.h b/ps3/ps3_video_psgl.h index eb4a935ee6..f0dceb6187 100644 --- a/ps3/ps3_video_psgl.h +++ b/ps3/ps3_video_psgl.h @@ -33,7 +33,6 @@ enum #define MAX_SCALING_FACTOR (4.0f) const char * ps3_get_resolution_label(uint32_t resolution); -int ps3_check_resolution(uint32_t resolution_id); void ps3_previous_resolution (void); void ps3_next_resolution (void); diff --git a/ps3/shared.h b/ps3/shared.h index 09b656d3ff..7f6bb507ca 100644 --- a/ps3/shared.h +++ b/ps3/shared.h @@ -17,28 +17,6 @@ #ifndef _PS3_SHARED_H #define _PS3_SHARED_H -#define MAX_PATH_LENGTH 1024 - -/* ABGR color format */ - -#define WHITE 0xffffffffu -#define RED 0xff0000ffu -#define GREEN 0xff00ff00u -#define BLUE 0xffff0000u -#define YELLOW 0xff00ffffu -#define PURPLE 0xffff00ffu -#define CYAN 0xffffff00u -#define ORANGE 0xff0063ffu -#define SILVER 0xff8c848cu -#define LIGHTBLUE 0xFFFFE0E0U -#define LIGHTORANGE 0xFFE0EEFFu - -enum -{ - EXTERN_LAUNCHER_SALAMANDER, - EXTERN_LAUNCHER_MULTIMAN -}; - enum { CONFIG_FILE, @@ -46,46 +24,19 @@ enum INPUT_PRESET_FILE }; -enum -{ - SOUND_MODE_NORMAL, - SOUND_MODE_RSOUND, - SOUND_MODE_HEADSET -}; - -enum { - MENU_ITEM_LOAD_STATE = 0, - MENU_ITEM_SAVE_STATE, - MENU_ITEM_KEEP_ASPECT_RATIO, - MENU_ITEM_OVERSCAN_AMOUNT, - MENU_ITEM_ORIENTATION, - MENU_ITEM_SCALE_FACTOR, - MENU_ITEM_RESIZE_MODE, - MENU_ITEM_FRAME_ADVANCE, - MENU_ITEM_SCREENSHOT_MODE, - MENU_ITEM_RESET, - MENU_ITEM_RETURN_TO_GAME, - MENU_ITEM_RETURN_TO_MENU, - MENU_ITEM_CHANGE_LIBRETRO, - MENU_ITEM_RETURN_TO_MULTIMAN, - MENU_ITEM_RETURN_TO_XMB -}; - -#define MENU_ITEM_LAST MENU_ITEM_RETURN_TO_XMB+1 - -extern char contentInfoPath[MAX_PATH_LENGTH]; -extern char usrDirPath[MAX_PATH_LENGTH]; -extern char DEFAULT_PRESET_FILE[MAX_PATH_LENGTH]; -extern char DEFAULT_BORDER_FILE[MAX_PATH_LENGTH]; -extern char DEFAULT_MENU_BORDER_FILE[MAX_PATH_LENGTH]; -extern char PRESETS_DIR_PATH[MAX_PATH_LENGTH]; -extern char INPUT_PRESETS_DIR_PATH[MAX_PATH_LENGTH]; -extern char BORDERS_DIR_PATH[MAX_PATH_LENGTH]; -extern char SHADERS_DIR_PATH[MAX_PATH_LENGTH]; -extern char DEFAULT_SHADER_FILE[MAX_PATH_LENGTH]; -extern char DEFAULT_MENU_SHADER_FILE[MAX_PATH_LENGTH]; -extern char LIBRETRO_DIR_PATH[MAX_PATH_LENGTH]; -extern char SYS_CONFIG_FILE[MAX_PATH_LENGTH]; -extern char MULTIMAN_EXECUTABLE[MAX_PATH_LENGTH]; +extern char contentInfoPath[PATH_MAX]; +extern char usrDirPath[PATH_MAX]; +extern char DEFAULT_PRESET_FILE[PATH_MAX]; +extern char DEFAULT_BORDER_FILE[PATH_MAX]; +extern char DEFAULT_MENU_BORDER_FILE[PATH_MAX]; +extern char PRESETS_DIR_PATH[PATH_MAX]; +extern char INPUT_PRESETS_DIR_PATH[PATH_MAX]; +extern char BORDERS_DIR_PATH[PATH_MAX]; +extern char SHADERS_DIR_PATH[PATH_MAX]; +extern char DEFAULT_SHADER_FILE[PATH_MAX]; +extern char DEFAULT_MENU_SHADER_FILE[PATH_MAX]; +extern char LIBRETRO_DIR_PATH[PATH_MAX]; +extern char SYS_CONFIG_FILE[PATH_MAX]; +extern char MULTIMAN_EXECUTABLE[PATH_MAX]; #endif diff --git a/retroarch.c b/retroarch.c index 9b76be6f5e..a3577c1ce4 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1152,7 +1152,12 @@ static void init_recording(void) params.fb_height = next_pow2(max_height); } - RARCH_LOG("Recording with FFmpeg to %s @ %ux%u. (FB size: %ux%u 32-bit: %s)\n", g_extern.record_path, params.out_width, params.out_height, params.fb_width, params.fb_height, params.rgb32 ? "yes" : "no"); + RARCH_LOG("Recording with FFmpeg to %s @ %ux%u. (FB size: %ux%u 32-bit: %s)\n", + g_extern.record_path, + params.out_width, params.out_height, + params.fb_width, params.fb_height, + params.rgb32 ? "yes" : "no"); + g_extern.rec = ffemu_new(¶ms); if (!g_extern.rec) { @@ -1171,7 +1176,7 @@ static void deinit_recording(void) } #endif -static void init_msg_queue(void) +void rarch_init_msg_queue(void) { if (g_extern.msg_queue) return; @@ -1179,7 +1184,7 @@ static void init_msg_queue(void) rarch_assert(g_extern.msg_queue = msg_queue_new(8)); } -static void deinit_msg_queue(void) +void rarch_deinit_msg_queue(void) { if (g_extern.msg_queue) { @@ -2363,7 +2368,6 @@ int rarch_main_init(int argc, char *argv[]) goto error; init_system_av_info(); - init_msg_queue(); if (!g_extern.sram_load_disable) load_save_files(); @@ -2543,7 +2547,6 @@ void rarch_main_deinit(void) #ifdef HAVE_BSV_MOVIE deinit_movie(); #endif - deinit_msg_queue(); pretro_unload_game(); pretro_deinit(); @@ -2560,8 +2563,10 @@ int main(int argc, char *argv[]) #endif int init_ret; if ((init_ret = rarch_main_init(argc, argv))) return init_ret; + rarch_init_msg_queue(); while (rarch_main_iterate()); rarch_main_deinit(); + rarch_deinit_msg_queue(); rarch_main_clear_state(); return 0; } diff --git a/settings.c b/settings.c index 3a6319a766..b80e68a4c9 100644 --- a/settings.c +++ b/settings.c @@ -212,6 +212,8 @@ void config_set_defaults(void) g_settings.input.netplay_client_swap_input = netplay_client_swap_input; for (int i = 0; i < MAX_PLAYERS; i++) g_settings.input.joypad_map[i] = i; + + rarch_init_msg_queue(); } #ifdef HAVE_CONFIGFILE diff --git a/wii/main.c b/wii/main.c index 9a4fb96bbc..f3de106460 100644 --- a/wii/main.c +++ b/wii/main.c @@ -135,7 +135,7 @@ int main(void) log_fp = fopen("sd:/ssnes-log.txt", "w"); #endif - rarch_assert(g_extern.msg_queue = msg_queue_new(8)); + config_set_defaults(); wii_video_init(); input_wii.init(); diff --git a/xenon/main.c b/xenon/main.c index 5cb606220d..7aedb5b39e 100644 --- a/xenon/main.c +++ b/xenon/main.c @@ -40,7 +40,7 @@ static void start_ssnes(const char *path) { char arg0[] = "ssnes"; char arg1[256]; - strncpy(arg1, path, sizeof(arg1)); + strlcpy(arg1, path, sizeof(arg1)); char *argv[3] = { arg0, arg1, NULL }; rarch_main(sizeof(argv) / sizeof(argv[0]) - 1, argv); }