Fixed indenting in a lot of console files

This commit is contained in:
Twinaphex 2012-04-10 21:23:42 +02:00
parent 867df49fcf
commit db00f689c8
12 changed files with 2655 additions and 2651 deletions

View File

@ -127,7 +127,7 @@ void xdk360_console_deinit()
}
// Destroy the font
xdk360_video_font_deinit(&m_Font);
xdk360_video_font_deinit(&m_Font);
}
void xdk360_console_add( wchar_t wch )
@ -135,11 +135,11 @@ 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 ) );
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;
}
@ -180,85 +180,84 @@ void xdk360_console_add( wchar_t wch )
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 ) );
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 );
va_list pArgList;
va_start( pArgList, strFormat );
// 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 );
}
// 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 );
_freea( strMessage );
// 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 );
}
va_end( pArgList );
_freea( strMessage );
va_end( pArgList );
}
void xdk360_console_format_w(_In_z_ _Printf_format_string_ LPCWSTR wstrFormat, ... )
{
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 ) );
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, wstrFormat );
va_list pArgList;
va_start( pArgList, wstrFormat );
// Count the required length of the string
unsigned long dwStrLen = _vscwprintf( wstrFormat, pArgList ) + 1; // +1 = null terminator
wchar_t * strMessage = ( wchar_t * )_malloca( dwStrLen * sizeof( wchar_t ) );
vswprintf_s( strMessage, dwStrLen, wstrFormat, pArgList );
// Count the required length of the string
unsigned long dwStrLen = _vscwprintf( wstrFormat, pArgList ) + 1; // +1 = null terminator
wchar_t * strMessage = ( wchar_t * )_malloca( dwStrLen * sizeof( wchar_t ) );
vswprintf_s( strMessage, dwStrLen, wstrFormat, pArgList );
// Output the string to the console
unsigned long uStringLength = wcslen( strMessage );
for( unsigned long i = 0; i < uStringLength; i++ )
xdk360_console_add( strMessage[i] );
// Output the string to the console
unsigned long uStringLength = wcslen( strMessage );
for( unsigned long i = 0; i < uStringLength; i++ )
xdk360_console_add( strMessage[i] );
_freea( strMessage );
_freea( strMessage );
va_end( pArgList );
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.
// Entry 0 maps to the "Unknown" glyph.
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
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;
@ -334,8 +333,7 @@ static HRESULT xdk360_video_font_create_shaders (xdk360_video_font_t * font)
{
// Use the do {} while(0); trick for a fake goto
// It simplies tear down on error conditions.
do
{
do{
// Step #1, create my vertex array with 16 bytes per entry
// Floats for the position,
@ -414,83 +412,83 @@ static HRESULT xdk360_video_font_create_shaders (xdk360_video_font_t * font)
void xdk360_video_font_set_size(xdk360_video_font_t * font, float x, float y)
{
font->m_fXScaleFactor = x;
font->m_fYScaleFactor = y;
font->m_fXScaleFactor = x;
font->m_fYScaleFactor = y;
}
HRESULT xdk360_video_font_init(xdk360_video_font_t * font, const char * strFontFileName)
{
font->m_pFontTexture = NULL;
font->m_dwNumGlyphs = 0L;
font->m_Glyphs = NULL;
font->m_fCursorX = 0.0f;
font->m_fCursorY = 0.0f;
font->m_fXScaleFactor = 2.0f;
font->m_fYScaleFactor = 2.0f;
font->m_cMaxGlyph = 0;
font->m_TranslatorTable = NULL;
font->m_dwNestedBeginCount = 0L;
font->m_pFontTexture = NULL;
font->m_dwNumGlyphs = 0L;
font->m_Glyphs = NULL;
font->m_fCursorX = 0.0f;
font->m_fCursorY = 0.0f;
font->m_fXScaleFactor = 2.0f;
font->m_fYScaleFactor = 2.0f;
font->m_cMaxGlyph = 0;
font->m_TranslatorTable = NULL;
font->m_dwNestedBeginCount = 0L;
// Create the font
if( FAILED( m_xprResource.Create( strFontFileName ) ) )
return E_FAIL;
// Create the font
if( FAILED( m_xprResource.Create( strFontFileName ) ) )
return E_FAIL;
D3DTexture * pFontTexture = m_xprResource.GetTexture( "FontTexture" );
const void * pFontData = m_xprResource.GetData( "FontData");
D3DTexture * pFontTexture = m_xprResource.GetTexture( "FontTexture" );
const void * pFontData = m_xprResource.GetData( "FontData");
// Save a copy of the texture
font->m_pFontTexture = pFontTexture;
// Save a copy of the texture
font->m_pFontTexture = pFontTexture;
// Check version of file (to make sure it matches up with the FontMaker tool)
const unsigned char * pData = static_cast<const unsigned char *>(pFontData);
unsigned long dwFileVersion = reinterpret_cast<const FontFileHeaderImage_t *>(pData)->m_dwFileVersion;
// Check version of file (to make sure it matches up with the FontMaker tool)
const unsigned char * pData = static_cast<const unsigned char *>(pFontData);
unsigned long dwFileVersion = reinterpret_cast<const FontFileHeaderImage_t *>(pData)->m_dwFileVersion;
if( dwFileVersion == FONTFILEVERSION )
{
font->m_fFontHeight = reinterpret_cast<const FontFileHeaderImage_t *>(pData)->m_fFontHeight;
font->m_fFontTopPadding = reinterpret_cast<const FontFileHeaderImage_t *>(pData)->m_fFontTopPadding;
font->m_fFontBottomPadding = reinterpret_cast<const FontFileHeaderImage_t *>(pData)->m_fFontBottomPadding;
font->m_fFontYAdvance = reinterpret_cast<const FontFileHeaderImage_t *>(pData)->m_fFontYAdvance;
if( dwFileVersion == FONTFILEVERSION )
{
font->m_fFontHeight = reinterpret_cast<const FontFileHeaderImage_t *>(pData)->m_fFontHeight;
font->m_fFontTopPadding = reinterpret_cast<const FontFileHeaderImage_t *>(pData)->m_fFontTopPadding;
font->m_fFontBottomPadding = reinterpret_cast<const FontFileHeaderImage_t *>(pData)->m_fFontBottomPadding;
font->m_fFontYAdvance = reinterpret_cast<const FontFileHeaderImage_t *>(pData)->m_fFontYAdvance;
// Point to the translator string which immediately follows the 4 floats
font->m_cMaxGlyph = reinterpret_cast<const FontFileHeaderImage_t *>(pData)->m_cMaxGlyph;
font->m_TranslatorTable = const_cast<FontFileHeaderImage_t*>(reinterpret_cast<const FontFileHeaderImage_t *>(pData))->m_TranslatorTable;
// Point to the translator string which immediately follows the 4 floats
font->m_cMaxGlyph = reinterpret_cast<const FontFileHeaderImage_t *>(pData)->m_cMaxGlyph;
pData += CALCFONTFILEHEADERSIZE( font->m_cMaxGlyph + 1 );
font->m_TranslatorTable = const_cast<FontFileHeaderImage_t*>(reinterpret_cast<const FontFileHeaderImage_t *>(pData))->m_TranslatorTable;
// Read the glyph attributes from the file
font->m_dwNumGlyphs = reinterpret_cast<const FontFileStrikesImage_t *>(pData)->m_dwNumGlyphs;
font->m_Glyphs = reinterpret_cast<const FontFileStrikesImage_t *>(pData)->m_Glyphs; // Pointer
}
else
{
SSNES_ERR( "Incorrect version number on font file.\n" );
return E_FAIL;
}
pData += CALCFONTFILEHEADERSIZE( font->m_cMaxGlyph + 1 );
// Create the vertex and pixel shaders for rendering the font
if( FAILED( xdk360_video_font_create_shaders(font) ) )
{
SSNES_ERR( "Could not create font shaders.\n" );
return E_FAIL;
}
// Read the glyph attributes from the file
font->m_dwNumGlyphs = reinterpret_cast<const FontFileStrikesImage_t *>(pData)->m_dwNumGlyphs;
font->m_Glyphs = reinterpret_cast<const FontFileStrikesImage_t *>(pData)->m_Glyphs; // Pointer
}
else
{
SSNES_ERR( "Incorrect version number on font file.\n" );
return E_FAIL;
}
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
D3DDevice *pd3dDevice = vid->xdk360_render_device;
// Create the vertex and pixel shaders for rendering the font
if( FAILED( xdk360_video_font_create_shaders(font) ) )
{
SSNES_ERR( "Could not create font shaders.\n" );
return E_FAIL;
}
// Initialize the window
D3DDISPLAYMODE DisplayMode;
pd3dDevice->GetDisplayMode( 0, &DisplayMode );
font->m_rcWindow.x1 = 0;
font->m_rcWindow.y1 = 0;
font->m_rcWindow.x2 = DisplayMode.Width;
font->m_rcWindow.y2 = DisplayMode.Height;
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
D3DDevice *pd3dDevice = vid->xdk360_render_device;
// Determine whether we should save/restore state
font->m_bSaveState = TRUE;
// Initialize the window
D3DDISPLAYMODE DisplayMode;
pd3dDevice->GetDisplayMode( 0, &DisplayMode );
font->m_rcWindow.x1 = 0;
font->m_rcWindow.y1 = 0;
font->m_rcWindow.x2 = DisplayMode.Width;
font->m_rcWindow.y2 = DisplayMode.Height;
return S_OK;
// Determine whether we should save/restore state
font->m_bSaveState = TRUE;
return S_OK;
}
void xdk360_video_font_deinit(xdk360_video_font_t * font)

View File

@ -45,9 +45,9 @@
#define DEVICE_CACHE 11
typedef struct _STRING {
unsigned short Length;
unsigned short MaximumLength;
char * Buffer;
unsigned short Length;
unsigned short MaximumLength;
char * Buffer;
} STRING;
char DEFAULT_SHADER_FILE[MAX_PATH_LENGTH];
@ -63,532 +63,538 @@ int ssnes_main(int argc, char *argv[]);
static int DriveMounted(std::string path)
{
WIN32_FIND_DATA findFileData;
memset(&findFileData,0,sizeof(WIN32_FIND_DATA));
std::string searchcmd = path + "\\*.*";
HANDLE hFind = FindFirstFile(searchcmd.c_str(), &findFileData);
WIN32_FIND_DATA findFileData;
memset(&findFileData,0,sizeof(WIN32_FIND_DATA));
std::string searchcmd = path + "\\*.*";
HANDLE hFind = FindFirstFile(searchcmd.c_str(), &findFileData);
if (hFind == INVALID_HANDLE_VALUE)
return 0;
if (hFind == INVALID_HANDLE_VALUE)
return 0;
FindClose(hFind);
FindClose(hFind);
return 1;
return 1;
}
static int Mount( int Device, char* MountPoint )
{
char MountConv[260];
sprintf_s( MountConv,"\\??\\%s", MountPoint );
char MountConv[260];
char * SysPath = NULL;
char * SysPath = NULL;
switch( Device )
{
case DEVICE_MEMORY_UNIT0:
SysPath = "\\Device\\Mu0";
break;
case DEVICE_MEMORY_UNIT1:
SysPath = "\\Device\\Mu1";
break;
case DEVICE_MEMORY_ONBOARD:
SysPath = "\\Device\\BuiltInMuSfc";
break;
case DEVICE_CDROM0:
SysPath = "\\Device\\Cdrom0";
break;
case DEVICE_HARDISK0_PART1:
SysPath = "\\Device\\Harddisk0\\Partition1";
break;
case DEVICE_HARDISK0_SYSPART:
SysPath = "\\Device\\Harddisk0\\SystemPartition";
break;
case DEVICE_USB0:
SysPath = "\\Device\\Mass0";
break;
case DEVICE_USB1:
SysPath = "\\Device\\Mass1";
break;
case DEVICE_USB2:
SysPath = "\\Device\\Mass2";
break;
case DEVICE_CACHE:
SysPath = "\\Device\\Harddisk0\\Cache0";
break;
sprintf_s( MountConv,"\\??\\%s", MountPoint );
}
switch( Device )
{
case DEVICE_MEMORY_UNIT0:
SysPath = "\\Device\\Mu0";
break;
case DEVICE_MEMORY_UNIT1:
SysPath = "\\Device\\Mu1";
break;
case DEVICE_MEMORY_ONBOARD:
SysPath = "\\Device\\BuiltInMuSfc";
break;
case DEVICE_CDROM0:
SysPath = "\\Device\\Cdrom0";
break;
case DEVICE_HARDISK0_PART1:
SysPath = "\\Device\\Harddisk0\\Partition1";
break;
case DEVICE_HARDISK0_SYSPART:
SysPath = "\\Device\\Harddisk0\\SystemPartition";
break;
case DEVICE_USB0:
SysPath = "\\Device\\Mass0";
break;
case DEVICE_USB1:
SysPath = "\\Device\\Mass1";
break;
case DEVICE_USB2:
SysPath = "\\Device\\Mass2";
break;
case DEVICE_CACHE:
SysPath = "\\Device\\Harddisk0\\Cache0";
break;
}
STRING sSysPath = { (USHORT)strlen( SysPath ), (USHORT)strlen( SysPath ) + 1, SysPath };
STRING sMountConv = { (USHORT)strlen( MountConv ), (USHORT)strlen( MountConv ) + 1, MountConv };
int res = ObCreateSymbolicLink( &sMountConv, &sSysPath );
STRING sSysPath = { (USHORT)strlen( SysPath ), (USHORT)strlen( SysPath ) + 1, SysPath };
STRING sMountConv = { (USHORT)strlen( MountConv ), (USHORT)strlen( MountConv ) + 1, MountConv };
int res = ObCreateSymbolicLink( &sMountConv, &sSysPath );
if (res != 0)
return res;
if (res != 0)
return res;
return DriveMounted(MountPoint);
return DriveMounted(MountPoint);
}
static void set_default_settings (void)
{
//g_settings
g_settings.rewind_enable = false;
strlcpy(g_settings.video.cg_shader_path, DEFAULT_SHADER_FILE, sizeof(g_settings.video.cg_shader_path));
g_settings.video.vsync = true;
g_settings.video.smooth = true;
g_settings.video.aspect_ratio = -1.0f;
//g_settings
g_settings.rewind_enable = false;
strlcpy(g_settings.video.cg_shader_path, DEFAULT_SHADER_FILE, sizeof(g_settings.video.cg_shader_path));
g_settings.video.vsync = true;
g_settings.video.smooth = true;
g_settings.video.aspect_ratio = -1.0f;
ssnes_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_B] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_A];
ssnes_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_Y] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_X];
ssnes_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_SELECT] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_BACK];
ssnes_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_START] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_START];
ssnes_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_UP] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_UP];
ssnes_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_DOWN] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_DOWN];
ssnes_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_LEFT] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_LEFT];
ssnes_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_RIGHT] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_RIGHT];
ssnes_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_A] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_B];
ssnes_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_X] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_Y];
ssnes_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_L] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_LB];
ssnes_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_R] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_RB];
ssnes_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_B] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_A];
ssnes_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_Y] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_X];
ssnes_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_SELECT] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_BACK];
ssnes_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_START] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_START];
ssnes_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_UP] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_UP];
ssnes_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_DOWN] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_DOWN];
ssnes_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_LEFT] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_LEFT];
ssnes_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_RIGHT] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_RIGHT];
ssnes_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_A] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_B];
ssnes_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_X] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_Y];
ssnes_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_L] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_LB];
ssnes_default_keybind_lut[RETRO_DEVICE_ID_JOYPAD_R] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_RB];
for(uint32_t x = 0; x < MAX_PLAYERS; x++)
{
for(uint32_t y = 0; y < SSNES_FIRST_META_KEY; y++)
{
g_settings.input.binds[x][y].id = y;
g_settings.input.binds[x][y].joykey = ssnes_default_keybind_lut[y];
}
g_settings.input.dpad_emulation[x] = DPAD_EMULATION_LSTICK;
}
for(uint32_t x = 0; x < MAX_PLAYERS; x++)
{
for(uint32_t y = 0; y < SSNES_FIRST_META_KEY; y++)
{
g_settings.input.binds[x][y].id = y;
g_settings.input.binds[x][y].joykey = ssnes_default_keybind_lut[y];
}
g_settings.input.dpad_emulation[x] = DPAD_EMULATION_LSTICK;
}
//g_console
g_console.block_config_read = true;
g_console.gamma_correction_enable = false;
g_console.initialize_ssnes_enable = false;
g_console.emulator_initialized = 0;
g_console.mode_switch = MODE_MENU;
g_console.screen_orientation = ORIENTATION_NORMAL;
g_console.throttle_enable = true;
g_console.aspect_ratio_index = 0;
strlcpy(g_console.aspect_ratio_name, "4:3", sizeof(g_console.aspect_ratio_name));
strlcpy(g_console.default_rom_startup_dir, "game:", sizeof(g_console.default_rom_startup_dir));
g_console.custom_viewport_width = 0;
g_console.custom_viewport_height = 0;
g_console.custom_viewport_x = 0;
g_console.custom_viewport_y = 0;
//g_console
g_console.block_config_read = true;
g_console.gamma_correction_enable = false;
g_console.initialize_ssnes_enable = false;
g_console.emulator_initialized = 0;
g_console.mode_switch = MODE_MENU;
g_console.screen_orientation = ORIENTATION_NORMAL;
g_console.throttle_enable = true;
g_console.aspect_ratio_index = 0;
strlcpy(g_console.aspect_ratio_name, "4:3", sizeof(g_console.aspect_ratio_name));
strlcpy(g_console.default_rom_startup_dir, "game:", sizeof(g_console.default_rom_startup_dir));
g_console.custom_viewport_width = 0;
g_console.custom_viewport_height = 0;
g_console.custom_viewport_x = 0;
g_console.custom_viewport_y = 0;
//g_extern
g_extern.state_slot = 0;
g_extern.audio_data.mute = 0;
g_extern.verbose = true;
//g_extern
g_extern.state_slot = 0;
g_extern.audio_data.mute = 0;
g_extern.verbose = true;
}
static char **dir_list_new_360(const char *dir, const char *ext)
{
size_t cur_ptr = 0;
size_t cur_size = 32;
char **dir_list = NULL;
size_t cur_ptr = 0;
size_t cur_size = 32;
char **dir_list = NULL;
WIN32_FIND_DATA ffd;
HANDLE hFind = INVALID_HANDLE_VALUE;
WIN32_FIND_DATA ffd;
HANDLE hFind = INVALID_HANDLE_VALUE;
char path_buf[PATH_MAX];
char path_buf[PATH_MAX];
if (strlcpy(path_buf, dir, sizeof(path_buf)) >= sizeof(path_buf))
goto error;
if (strlcat(path_buf, "*", sizeof(path_buf)) >= sizeof(path_buf))
goto error;
if (strlcpy(path_buf, dir, sizeof(path_buf)) >= sizeof(path_buf))
goto error;
if (strlcat(path_buf, "*", sizeof(path_buf)) >= sizeof(path_buf))
goto error;
if (ext)
{
if (strlcat(path_buf, ext, sizeof(path_buf)) >= sizeof(path_buf))
goto error;
}
if (ext)
{
if (strlcat(path_buf, ext, sizeof(path_buf)) >= sizeof(path_buf))
goto error;
}
hFind = FindFirstFile(path_buf, &ffd);
if (hFind == INVALID_HANDLE_VALUE)
goto error;
hFind = FindFirstFile(path_buf, &ffd);
if (hFind == INVALID_HANDLE_VALUE)
goto error;
dir_list = (char**)calloc(cur_size, sizeof(char*));
if (!dir_list)
goto error;
dir_list = (char**)calloc(cur_size, sizeof(char*));
if (!dir_list)
goto error;
do
{
// Not a perfect search of course, but hopefully good enough in practice.
if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
continue;
if (ext && !strstr(ffd.cFileName, ext))
continue;
do
{
// Not a perfect search of course, but hopefully good enough in practice.
if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
continue;
if (ext && !strstr(ffd.cFileName, ext))
continue;
dir_list[cur_ptr] = (char*)malloc(PATH_MAX);
if (!dir_list[cur_ptr])
goto error;
dir_list[cur_ptr] = (char*)malloc(PATH_MAX);
if (!dir_list[cur_ptr])
goto error;
strlcpy(dir_list[cur_ptr], dir, PATH_MAX);
strlcat(dir_list[cur_ptr], ffd.cFileName, PATH_MAX);
strlcpy(dir_list[cur_ptr], dir, PATH_MAX);
strlcat(dir_list[cur_ptr], ffd.cFileName, PATH_MAX);
cur_ptr++;
if (cur_ptr + 1 == cur_size) // Need to reserve for NULL.
{
cur_size *= 2;
dir_list = (char**)realloc(dir_list, cur_size * sizeof(char*));
if (!dir_list)
goto error;
cur_ptr++;
if (cur_ptr + 1 == cur_size) // Need to reserve for NULL.
{
cur_size *= 2;
dir_list = (char**)realloc(dir_list, cur_size * sizeof(char*));
if (!dir_list)
goto error;
// Make sure it's all NULL'd out since we cannot rely on realloc to do this.
memset(dir_list + cur_ptr, 0, (cur_size - cur_ptr) * sizeof(char*));
}
}while (FindNextFile(hFind, &ffd) != 0);
// Make sure it's all NULL'd out since we cannot rely on realloc to do this.
memset(dir_list + cur_ptr, 0, (cur_size - cur_ptr) * sizeof(char*));
}
}while (FindNextFile(hFind, &ffd) != 0);
FindClose(hFind);
return dir_list;
FindClose(hFind);
return dir_list;
error:
SSNES_ERR("Failed to open directory: \"%s\"\n", dir);
if (hFind != INVALID_HANDLE_VALUE)
FindClose(hFind);
dir_list_free(dir_list);
return NULL;
error:
SSNES_ERR("Failed to open directory: \"%s\"\n", dir);
if (hFind != INVALID_HANDLE_VALUE)
FindClose(hFind);
dir_list_free(dir_list);
return NULL;
}
static void init_settings (bool load_libretro_path)
{
char fname_tmp[MAX_PATH_LENGTH];
char fname_tmp[MAX_PATH_LENGTH];
if(!path_file_exists(SYS_CONFIG_FILE))
{
SSNES_ERR("Config file \"%s\" desn't exist. Creating...\n", "game:\\ssnes.cfg");
FILE * f;
f = fopen(SYS_CONFIG_FILE, "w");
fclose(f);
}
if(!path_file_exists(SYS_CONFIG_FILE))
{
FILE * f;
SSNES_ERR("Config file \"%s\" desn't exist. Creating...\n", "game:\\ssnes.cfg");
f = fopen(SYS_CONFIG_FILE, "w");
fclose(f);
}
config_file_t * conf = config_file_new(SYS_CONFIG_FILE);
config_file_t * conf = config_file_new(SYS_CONFIG_FILE);
if(load_libretro_path)
{
CONFIG_GET_STRING(libretro, "libretro_path");
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_360("game:\\", ".xex");
if (!dir_list)
{
SSNES_ERR("Couldn't read directory.\n");
return;
}
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_360("game:\\", ".xex");
const char * first_xex = dir_list[0];
if (!dir_list)
{
SSNES_ERR("Couldn't read directory.\n");
return;
}
if(first_xex)
{
fill_pathname_base(fname_tmp, first_xex, sizeof(fname_tmp));
const char * first_xex = dir_list[0];
if(strcmp(fname_tmp, "SSNES-Salamander.xex") == 0)
{
SSNES_WARN("First entry is SSNES 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
SSNES_WARN("There is no second entry - no choice but to set it to SSNES Salamander\n");
first_xex = dir_list[0];
fill_pathname_base(fname_tmp, first_xex, sizeof(fname_tmp));
}
}
SSNES_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
{
SSNES_ERR("Failed to set first .xex entry to libretro path.\n");
}
if(first_xex)
{
fill_pathname_base(fname_tmp, first_xex, sizeof(fname_tmp));
dir_list_free(dir_list);
}
}
if(strcmp(fname_tmp, "SSNES-Salamander.xex") == 0)
{
SSNES_WARN("First entry is SSNES 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));
// g_settings
CONFIG_GET_BOOL(rewind_enable, "rewind_enable");
CONFIG_GET_BOOL(video.smooth, "video_smooth");
CONFIG_GET_BOOL(video.vsync, "video_vsync");
CONFIG_GET_FLOAT(video.aspect_ratio, "video_aspect_ratio");
if(!first_xex)
{
//This is very unlikely to happen
SSNES_WARN("There is no second entry - no choice but to set it to SSNES Salamander\n");
first_xex = dir_list[0];
fill_pathname_base(fname_tmp, first_xex, sizeof(fname_tmp));
}
}
SSNES_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
{
SSNES_ERR("Failed to set first .xex entry to libretro path.\n");
}
// g_console
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(screen_orientation, "screen_orientation");
CONFIG_GET_STRING_CONSOLE(aspect_ratio_name, "aspect_ratio_name");
dir_list_free(dir_list);
}
}
// g_extern
CONFIG_GET_INT_EXTERN(state_slot, "state_slot");
CONFIG_GET_INT_EXTERN(audio_data.mute, "audio_mute");
// g_settings
CONFIG_GET_BOOL(rewind_enable, "rewind_enable");
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(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(screen_orientation, "screen_orientation");
CONFIG_GET_STRING_CONSOLE(aspect_ratio_name, "aspect_ratio_name");
// 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);
}
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);
config_file_t * conf = config_file_new(SYS_CONFIG_FILE);
if(conf == NULL)
conf = config_file_new(NULL);
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_bool(conf, "video_smooth", g_settings.video.smooth);
config_set_bool(conf, "video_vsync", g_settings.video.vsync);
// g_settings
config_set_string(conf, "libretro_path", g_settings.libretro);
config_set_bool(conf, "rewind_enable", g_settings.rewind_enable);
config_set_bool(conf, "video_smooth", g_settings.video.smooth);
config_set_bool(conf, "video_vsync", g_settings.video.vsync);
// g_console
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.custom_viewport_width);
config_set_int(conf, "custom_viewport_height", g_console.custom_viewport_height);
config_set_int(conf, "custom_viewport_x", g_console.custom_viewport_x);
config_set_int(conf, "custom_viewport_y", g_console.custom_viewport_y);
config_set_int(conf, "screen_orientation", g_console.screen_orientation);
config_set_string(conf, "aspect_ratio_name", g_console.aspect_ratio_name);
// g_console
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.custom_viewport_width);
config_set_int(conf, "custom_viewport_height", g_console.custom_viewport_height);
config_set_int(conf, "custom_viewport_x", g_console.custom_viewport_x);
config_set_int(conf, "custom_viewport_y", g_console.custom_viewport_y);
config_set_int(conf, "screen_orientation", g_console.screen_orientation);
config_set_string(conf, "aspect_ratio_name", g_console.aspect_ratio_name);
// g_extern
config_set_int(conf, "state_slot", g_extern.state_slot);
config_set_int(conf, "audio_mute", g_extern.audio_data.mute);
// 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))
SSNES_ERR("Failed to write config file to \"%s\". Check permissions.\n", SYS_CONFIG_FILE);
if (!config_file_write(conf, SYS_CONFIG_FILE))
SSNES_ERR("Failed to write config file to \"%s\". Check permissions.\n", SYS_CONFIG_FILE);
free(conf);
free(conf);
}
static void get_environment_settings (void)
{
DWORD ret;
DWORD ret;
//for devkits only, we will need to mount all partitions for retail
//in a different way
//DmMapDevkitDrive();
memset(&Mounted, 0, 20);
//for devkits only, we will need to mount all partitions for retail
//in a different way
//DmMapDevkitDrive();
Mounted[DEVICE_USB0] = Mount(DEVICE_USB0,"Usb0:");
Mounted[DEVICE_USB1] = Mount(DEVICE_USB1,"Usb1:");
Mounted[DEVICE_USB2] = Mount(DEVICE_USB2,"Usb2:");
Mounted[DEVICE_HARDISK0_PART1] = Mount(DEVICE_HARDISK0_PART1,"Hdd1:");
Mounted[DEVICE_HARDISK0_SYSPART] = Mount(DEVICE_HARDISK0_SYSPART,"HddX:");
Mounted[DEVICE_MEMORY_UNIT0] = Mount(DEVICE_MEMORY_UNIT0,"Memunit0:");
Mounted[DEVICE_MEMORY_UNIT1] = Mount(DEVICE_MEMORY_UNIT1,"Memunit1:");
Mounted[DEVICE_MEMORY_ONBOARD] = Mount(DEVICE_MEMORY_ONBOARD,"OnBoardMU:");
Mounted[DEVICE_CDROM0] = Mount(DEVICE_CDROM0,"Dvd:");
memset(&Mounted, 0, 20);
ret = XSetFileCacheSize(0x100000);
Mounted[DEVICE_USB0] = Mount(DEVICE_USB0,"Usb0:");
Mounted[DEVICE_USB1] = Mount(DEVICE_USB1,"Usb1:");
Mounted[DEVICE_USB2] = Mount(DEVICE_USB2,"Usb2:");
Mounted[DEVICE_HARDISK0_PART1] = Mount(DEVICE_HARDISK0_PART1,"Hdd1:");
Mounted[DEVICE_HARDISK0_SYSPART] = Mount(DEVICE_HARDISK0_SYSPART,"HddX:");
Mounted[DEVICE_MEMORY_UNIT0] = Mount(DEVICE_MEMORY_UNIT0,"Memunit0:");
Mounted[DEVICE_MEMORY_UNIT1] = Mount(DEVICE_MEMORY_UNIT1,"Memunit1:");
Mounted[DEVICE_MEMORY_ONBOARD] = Mount(DEVICE_MEMORY_ONBOARD,"OnBoardMU:");
Mounted[DEVICE_CDROM0] = Mount(DEVICE_CDROM0,"Dvd:");
if(ret != TRUE)
{
SSNES_ERR("Couldn't change number of bytes reserved for file system cache.\n");
}
ret = XSetFileCacheSize(0x100000);
ret = XFileCacheInit(XFILECACHE_CLEAR_ALL, 0x100000, XFILECACHE_DEFAULT_THREAD, 0, 1);
if(ret != TRUE)
{
SSNES_ERR("Couldn't change number of bytes reserved for file system cache.\n");
}
if(ret != ERROR_SUCCESS)
{
SSNES_ERR("File cache could not be initialized.\n");
}
ret = XFileCacheInit(XFILECACHE_CLEAR_ALL, 0x100000, XFILECACHE_DEFAULT_THREAD, 0, 1);
XFlushUtilityDrive();
//unsigned long result = XMountUtilityDriveEx(XMOUNTUTILITYDRIVE_FORMAT0,8192, 0);
if(ret != ERROR_SUCCESS)
{
SSNES_ERR("File cache could not be initialized.\n");
}
//if(result != ERROR_SUCCESS)
//{
// SSNES_ERR("Couldn't mount/format utility drive.\n");
//}
XFlushUtilityDrive();
//unsigned long result = XMountUtilityDriveEx(XMOUNTUTILITYDRIVE_FORMAT0,8192, 0);
// detect install environment
unsigned long license_mask;
//if(result != ERROR_SUCCESS)
//{
// SSNES_ERR("Couldn't mount/format utility drive.\n");
//}
if (XContentGetLicenseMask(&license_mask, NULL) != ERROR_SUCCESS)
{
printf("SSNES was launched as a standalone DVD, or using DVD emulation, or from the development area of the HDD.\n");
}
else
{
XContentQueryVolumeDeviceType("GAME",&g_console.volume_device_type, NULL);
// detect install environment
unsigned long license_mask;
switch(g_console.volume_device_type)
{
case XCONTENTDEVICETYPE_HDD:
printf("SSNES was launched from a content package on HDD.\n");
break;
case XCONTENTDEVICETYPE_MU:
printf("SSNES was launched from a content package on USB or Memory Unit.\n");
break;
case XCONTENTDEVICETYPE_ODD:
printf("SSNES was launched from a content package on Optical Disc Drive.\n");
break;
default:
printf("SSNES was launched from a content package on an unknown device type.\n");
break;
if (XContentGetLicenseMask(&license_mask, NULL) != ERROR_SUCCESS)
{
printf("SSNES was launched as a standalone DVD, or using DVD emulation, or from the development area of the HDD.\n");
}
else
{
XContentQueryVolumeDeviceType("GAME",&g_console.volume_device_type, NULL);
}
}
strlcpy(DEFAULT_SHADER_FILE, "game:\\media\\shaders\\stock.cg", sizeof(DEFAULT_SHADER_FILE));
strlcpy(SYS_CONFIG_FILE, "game:\\ssnes.cfg", sizeof(SYS_CONFIG_FILE));
switch(g_console.volume_device_type)
{
case XCONTENTDEVICETYPE_HDD:
printf("SSNES was launched from a content package on HDD.\n");
break;
case XCONTENTDEVICETYPE_MU:
printf("SSNES was launched from a content package on USB or Memory Unit.\n");
break;
case XCONTENTDEVICETYPE_ODD:
printf("SSNES was launched from a content package on Optical Disc Drive.\n");
break;
default:
printf("SSNES was launched from a content package on an unknown device type.\n");
break;
}
}
strlcpy(DEFAULT_SHADER_FILE, "game:\\media\\shaders\\stock.cg", sizeof(DEFAULT_SHADER_FILE));
strlcpy(SYS_CONFIG_FILE, "game:\\ssnes.cfg", sizeof(SYS_CONFIG_FILE));
}
static bool manage_libretro_core(void)
{
g_extern.verbose = true;
bool return_code;
g_extern.verbose = true;
bool return_code;
bool set_libretro_path = false;
char tmp_path[1024], tmp_path2[1024], tmp_pathnewfile[1024];
snprintf(tmp_path, sizeof(tmp_path), "game:\\CORE.xex");
SSNES_LOG("Assumed path of CORE.xex: [%s]\n", tmp_path);
if(path_file_exists(tmp_path))
{
//if CORE.xex exists, this indicates we have just installed
//a new libretro port and that we need to change it to a more
//sane name.
bool set_libretro_path = false;
char tmp_path[1024], tmp_path2[1024], tmp_pathnewfile[1024];
snprintf(tmp_path, sizeof(tmp_path), "game:\\CORE.xex");
SSNES_LOG("Assumed path of CORE.xex: [%s]\n", tmp_path);
int ret;
if(path_file_exists(tmp_path))
{
//if CORE.xex exists, this indicates we have just installed
//a new libretro port and that we need to change it to a more
//sane name.
ssnes_console_name_from_id(tmp_path2, sizeof(tmp_path2));
strlcat(tmp_path2, ".xex", sizeof(tmp_path2));
snprintf(tmp_pathnewfile, sizeof(tmp_pathnewfile), "game:\\%s", tmp_path2);
int ret;
if(path_file_exists(tmp_pathnewfile))
{
SSNES_LOG("Upgrading emulator core...\n");
//if libretro core already exists, then that means we are
//upgrading the libretro core - so delete pre-existing
//file first
ret = DeleteFile(tmp_pathnewfile);
if(ret != 0)
{
SSNES_LOG("Succeeded in removing pre-existing libretro core: [%s].\n", tmp_pathnewfile);
}
else
{
SSNES_LOG("Failed to remove pre-existing libretro core: [%s].\n", tmp_pathnewfile);
}
}
ssnes_console_name_from_id(tmp_path2, sizeof(tmp_path2));
strlcat(tmp_path2, ".xex", sizeof(tmp_path2));
snprintf(tmp_pathnewfile, sizeof(tmp_pathnewfile), "game:\\%s", tmp_path2);
//now attempt the renaming
ret = MoveFileExA(tmp_path, tmp_pathnewfile, NULL);
if(ret == 0)
{
SSNES_ERR("Failed to rename CORE.xex.\n");
}
else
{
SSNES_LOG("libretro core [%s] renamed to: [%s].\n", tmp_path, tmp_pathnewfile);
set_libretro_path = true;
}
}
else
{
SSNES_LOG("CORE.xex was not found, libretro core path will be loaded from config file.\n");
}
if(path_file_exists(tmp_pathnewfile))
{
SSNES_LOG("Upgrading emulator core...\n");
if(set_libretro_path)
{
//CORE.xex 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.xex present, or the CORE.xex file was not renamed.
//The libretro core path will still be loaded from the config file
return_code = 1;
}
//if libretro core already exists, then that means we are
//upgrading the libretro core - so delete pre-existing
//file first
ret = DeleteFile(tmp_pathnewfile);
if(ret != 0)
{
SSNES_LOG("Succeeded in removing pre-existing libretro core: [%s].\n", tmp_pathnewfile);
}
else
{
SSNES_LOG("Failed to remove pre-existing libretro core: [%s].\n", tmp_pathnewfile);
}
}
g_extern.verbose = false;
//now attempt the renaming
ret = MoveFileExA(tmp_path, tmp_pathnewfile, NULL);
if(ret == 0)
{
SSNES_ERR("Failed to rename CORE.xex.\n");
}
else
{
SSNES_LOG("libretro core [%s] renamed to: [%s].\n", tmp_path, tmp_pathnewfile);
set_libretro_path = true;
}
}
else
{
SSNES_LOG("CORE.xex was not found, libretro core path will be loaded from config file.\n");
}
return return_code;
if(set_libretro_path)
{
//CORE.xex 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.xex present, or the CORE.xex 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;
}
int main(int argc, char *argv[])
{
get_environment_settings();
get_environment_settings();
ssnes_main_clear_state();
config_set_defaults();
bool load_libretro_path = manage_libretro_core();
ssnes_main_clear_state();
config_set_defaults();
set_default_settings();
init_settings(load_libretro_path);
init_libretro_sym();
bool load_libretro_path = manage_libretro_core();
xdk360_video_init();
xdk360_input_init();
set_default_settings();
init_settings(load_libretro_path);
init_libretro_sym();
ssnes_input_set_default_keybind_names_for_emulator();
xdk360_video_init();
xdk360_input_init();
menu_init();
ssnes_input_set_default_keybind_names_for_emulator();
menu_init();
begin_loop:
if(g_console.mode_switch == MODE_EMULATION)
{
bool repeat = false;
if(g_console.mode_switch == MODE_EMULATION)
{
bool repeat = false;
input_xdk360.poll(NULL);
input_xdk360.poll(NULL);
do{
repeat = ssnes_main_iterate();
}while(repeat && !g_console.frame_advance_enable);
}
else if(g_console.mode_switch == MODE_MENU)
{
menu_loop();
do{
repeat = ssnes_main_iterate();
}while(repeat && !g_console.frame_advance_enable);
}
else if(g_console.mode_switch == MODE_MENU)
{
menu_loop();
if(g_console.initialize_ssnes_enable)
{
if(g_console.emulator_initialized)
ssnes_main_deinit();
if(g_console.initialize_ssnes_enable)
{
if(g_console.emulator_initialized)
ssnes_main_deinit();
struct ssnes_main_wrap args = {0};
struct ssnes_main_wrap args = {0};
args.verbose = g_extern.verbose;
args.config_path = SYS_CONFIG_FILE;
args.rom_path = g_console.rom_path;
int init_ret = ssnes_main_init_wrap(&args);
g_console.emulator_initialized = 1;
g_console.initialize_ssnes_enable = 0;
}
}
else
goto begin_shutdown;
args.verbose = g_extern.verbose;
args.config_path = SYS_CONFIG_FILE;
args.rom_path = g_console.rom_path;
goto begin_loop;
int init_ret = ssnes_main_init_wrap(&args);
g_console.emulator_initialized = 1;
g_console.initialize_ssnes_enable = 0;
}
}
else
goto begin_shutdown;
goto begin_loop;
begin_shutdown:
if(path_file_exists(SYS_CONFIG_FILE))
save_settings();
xdk360_video_deinit();
if(path_file_exists(SYS_CONFIG_FILE))
save_settings();
if(g_console.return_to_launcher)
{
SSNES_LOG("Attempt to load XEX: [%s].\n", g_console.launch_app_on_exit);
XLaunchNewImage(g_console.launch_app_on_exit, NULL);
}
return 0;
xdk360_video_deinit();
if(g_console.return_to_launcher)
{
SSNES_LOG("Attempt to load XEX: [%s].\n", g_console.launch_app_on_exit);
XLaunchNewImage(g_console.launch_app_on_exit, NULL);
}
return 0;
}

View File

@ -33,533 +33,539 @@ char strbuffer[1024];
static void return_to_game (void)
{
g_console.frame_advance_enable = false;
g_console.menu_enable = false;
g_console.mode_switch = MODE_EMULATION;
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_ssnes_enable = false;
g_console.menu_enable = false;
g_console.mode_switch = MODE_EXIT;
g_console.initialize_ssnes_enable = false;
}
/* Register custom classes */
HRESULT CSSNES::RegisterXuiClasses (void)
{
CSSNESMain::Register();
CSSNESFileBrowser::Register();
CSSNESCoreBrowser::Register();
CSSNESQuickMenu::Register();
CSSNESSettings::Register();
return S_OK;
CSSNESMain::Register();
CSSNESFileBrowser::Register();
CSSNESCoreBrowser::Register();
CSSNESQuickMenu::Register();
CSSNESSettings::Register();
return S_OK;
}
/* Unregister custom classes */
HRESULT CSSNES::UnregisterXuiClasses (void)
{
CSSNESMain::Unregister();
CSSNESCoreBrowser::Unregister();
CSSNESFileBrowser::Unregister();
CSSNESQuickMenu::Register();
CSSNESSettings::Unregister();
return S_OK;
CSSNESMain::Unregister();
CSSNESCoreBrowser::Unregister();
CSSNESFileBrowser::Unregister();
CSSNESQuickMenu::Register();
CSSNESSettings::Unregister();
return S_OK;
}
static void filebrowser_fetch_directory_entries(const char *path, filebrowser_t * browser, CXuiList * romlist,
CXuiTextElement * rompath_title)
{
filebrowser_push_directory(browser, path, true);
filebrowser_push_directory(browser, path, true);
unsigned long dwNum_rompath = MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0);
wchar_t * rompath_name = new wchar_t[dwNum_rompath];
MultiByteToWideChar(CP_ACP, 0, path, -1, rompath_name, dwNum_rompath);
rompath_title->SetText(rompath_name);
unsigned long dwNum_rompath = MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0);
wchar_t * rompath_name = new wchar_t[dwNum_rompath];
MultiByteToWideChar(CP_ACP, 0, path, -1, rompath_name, dwNum_rompath);
rompath_title->SetText(rompath_name);
romlist->DeleteItems(0, romlist->GetItemCount());
romlist->InsertItems(0, browser->file_count);
for(unsigned i = 0; i < browser->file_count; i++)
{
unsigned long dwNum = MultiByteToWideChar(CP_ACP, 0, browser->cur[i].d_name, -1, NULL, 0);
wchar_t * entry_name = new wchar_t[dwNum];
MultiByteToWideChar(CP_ACP, 0, browser->cur[i].d_name, -1, entry_name, dwNum);
romlist->SetText(i, entry_name);
delete []entry_name;
}
romlist->DeleteItems(0, romlist->GetItemCount());
romlist->InsertItems(0, browser->file_count);
for(unsigned i = 0; i < browser->file_count; i++)
{
unsigned long dwNum = MultiByteToWideChar(CP_ACP, 0, browser->cur[i].d_name, -1, NULL, 0);
wchar_t * entry_name = new wchar_t[dwNum];
MultiByteToWideChar(CP_ACP, 0, browser->cur[i].d_name, -1, entry_name, dwNum);
romlist->SetText(i, entry_name);
delete []entry_name;
}
}
HRESULT CSSNESFileBrowser::OnInit(XUIMessageInit * pInitData, BOOL& bHandled)
{
GetChildById(L"XuiRomList", &m_romlist);
GetChildById(L"XuiBackButton1", &m_back);
GetChildById(L"XuiTxtRomPath", &m_rompathtitle);
GetChildById(L"XuiBtnGameDir", &m_dir_game);
GetChildById(L"XuiBtnCacheDir", &m_dir_cache);
GetChildById(L"XuiRomList", &m_romlist);
GetChildById(L"XuiBackButton1", &m_back);
GetChildById(L"XuiTxtRomPath", &m_rompathtitle);
GetChildById(L"XuiBtnGameDir", &m_dir_game);
GetChildById(L"XuiBtnCacheDir", &m_dir_cache);
filebrowser_fetch_directory_entries(g_console.default_rom_startup_dir, &browser, &m_romlist, &m_rompathtitle);
filebrowser_fetch_directory_entries(g_console.default_rom_startup_dir, &browser, &m_romlist, &m_rompathtitle);
return S_OK;
return S_OK;
}
HRESULT CSSNESCoreBrowser::OnInit(XUIMessageInit * pInitData, BOOL& bHandled)
{
GetChildById(L"XuiRomList", &m_romlist);
GetChildById(L"XuiBackButton1", &m_back);
GetChildById(L"XuiTxtRomPath", &m_rompathtitle);
filebrowser_new(&tmp_browser, "game:", "xex|XEX");
filebrowser_fetch_directory_entries("game:", &tmp_browser, &m_romlist, &m_rompathtitle);
GetChildById(L"XuiRomList", &m_romlist);
GetChildById(L"XuiBackButton1", &m_back);
GetChildById(L"XuiTxtRomPath", &m_rompathtitle);
return S_OK;
filebrowser_new(&tmp_browser, "game:", "xex|XEX");
filebrowser_fetch_directory_entries("game:", &tmp_browser, &m_romlist, &m_rompathtitle);
return S_OK;
}
static const wchar_t * set_filter_element(int index)
{
switch(index)
{
case FALSE:
return L"Hardware filtering: Point filtering";
case TRUE:
return L"Hardware filtering: Linear interpolation";
}
switch(index)
{
case FALSE:
return L"Hardware filtering: Point filtering";
case TRUE:
return L"Hardware filtering: Linear interpolation";
}
return L"";
return L"";
}
HRESULT CSSNESSettings::OnInit(XUIMessageInit * pInitData, BOOL& bHandled)
{
GetChildById(L"XuiSettingsList", &m_settingslist);
GetChildById(L"XuiBackButton", &m_back);
GetChildById(L"XuiSettingsList", &m_settingslist);
GetChildById(L"XuiBackButton", &m_back);
m_settingslist.SetText(SETTING_EMU_REWIND_ENABLED, g_settings.rewind_enable ? L"Rewind: ON" : L"Rewind: OFF");
m_settingslist.SetText(SETTING_GAMMA_CORRECTION_ENABLED, g_console.gamma_correction_enable ? L"Gamma correction: ON" : L"Gamma correction: OFF");
m_settingslist.SetText(SETTING_HARDWARE_FILTERING, set_filter_element(g_settings.video.smooth));
return S_OK;
m_settingslist.SetText(SETTING_EMU_REWIND_ENABLED, g_settings.rewind_enable ? L"Rewind: ON" : L"Rewind: OFF");
m_settingslist.SetText(SETTING_GAMMA_CORRECTION_ENABLED, g_console.gamma_correction_enable ? L"Gamma correction: ON" : L"Gamma correction: OFF");
m_settingslist.SetText(SETTING_HARDWARE_FILTERING, set_filter_element(g_settings.video.smooth));
return S_OK;
}
HRESULT CSSNESQuickMenu::OnInit(XUIMessageInit * pInitData, BOOL& bHandled)
{
GetChildById(L"XuiQuickMenuList", &m_quickmenulist);
GetChildById(L"XuiBackButton", &m_back);
GetChildById(L"XuiQuickMenuList", &m_quickmenulist);
GetChildById(L"XuiBackButton", &m_back);
m_quickmenulist.SetText(MENU_ITEM_HARDWARE_FILTERING, set_filter_element(g_settings.video.smooth));
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];
sprintf(aspectratio_label, "Aspect Ratio: %s", g_console.aspect_ratio_name);
unsigned long dwNum = MultiByteToWideChar(CP_ACP, 0, aspectratio_label, -1, NULL, 0);
wchar_t * aspectratio_label_w = new wchar_t[dwNum];
MultiByteToWideChar(CP_ACP, 0, aspectratio_label, -1, aspectratio_label_w, dwNum);
m_quickmenulist.SetText(MENU_ITEM_KEEP_ASPECT_RATIO, aspectratio_label_w);
delete[] aspectratio_label_w;
return S_OK;
m_quickmenulist.SetText(MENU_ITEM_HARDWARE_FILTERING, set_filter_element(g_settings.video.smooth));
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];
sprintf(aspectratio_label, "Aspect Ratio: %s", g_console.aspect_ratio_name);
unsigned long dwNum = MultiByteToWideChar(CP_ACP, 0, aspectratio_label, -1, NULL, 0);
wchar_t * aspectratio_label_w = new wchar_t[dwNum];
MultiByteToWideChar(CP_ACP, 0, aspectratio_label, -1, aspectratio_label_w, dwNum);
m_quickmenulist.SetText(MENU_ITEM_KEEP_ASPECT_RATIO, aspectratio_label_w);
delete[] aspectratio_label_w;
return S_OK;
}
HRESULT CSSNESQuickMenu::OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled )
{
int current_index;
int current_index;
if ( hObjPressed == m_quickmenulist)
{
current_index = m_quickmenulist.GetCurSel();
if ( hObjPressed == m_quickmenulist)
{
current_index = m_quickmenulist.GetCurSel();
switch(current_index)
{
case MENU_ITEM_LOAD_STATE:
if (g_console.emulator_initialized)
{
ssnes_load_state();
return_to_game();
}
break;
case MENU_ITEM_SAVE_STATE:
if (g_console.emulator_initialized)
{
ssnes_save_state();
return_to_game();
}
break;
case MENU_ITEM_HARDWARE_FILTERING:
g_settings.video.smooth = !g_settings.video.smooth;
m_quickmenulist.SetText(MENU_ITEM_HARDWARE_FILTERING, set_filter_element(g_settings.video.smooth));
break;
case MENU_ITEM_KEEP_ASPECT_RATIO:
{
if(g_console.aspect_ratio_index < LAST_ASPECT_RATIO)
g_console.aspect_ratio_index++;
else
g_console.aspect_ratio_index = 0;
switch(current_index)
{
case MENU_ITEM_LOAD_STATE:
if (g_console.emulator_initialized)
{
ssnes_load_state();
return_to_game();
}
break;
case MENU_ITEM_SAVE_STATE:
if (g_console.emulator_initialized)
{
ssnes_save_state();
return_to_game();
}
break;
case MENU_ITEM_HARDWARE_FILTERING:
g_settings.video.smooth = !g_settings.video.smooth;
m_quickmenulist.SetText(MENU_ITEM_HARDWARE_FILTERING, set_filter_element(g_settings.video.smooth));
break;
case MENU_ITEM_KEEP_ASPECT_RATIO:
{
if(g_console.aspect_ratio_index < LAST_ASPECT_RATIO)
g_console.aspect_ratio_index++;
else
g_console.aspect_ratio_index = 0;
video_xdk360.set_aspect_ratio(NULL, g_console.aspect_ratio_index);
char aspectratio_label[32];
sprintf(aspectratio_label, "Aspect Ratio: %s", g_console.aspect_ratio_name);
unsigned long dwNum = MultiByteToWideChar(CP_ACP, 0, aspectratio_label, -1, NULL, 0);
wchar_t * aspectratio_label_w = new wchar_t[dwNum];
MultiByteToWideChar(CP_ACP, 0, aspectratio_label, -1, aspectratio_label_w, dwNum);
m_quickmenulist.SetText(MENU_ITEM_KEEP_ASPECT_RATIO, aspectratio_label_w);
delete[] aspectratio_label_w;
}
break;
case MENU_ITEM_OVERSCAN_AMOUNT:
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;
}
video_xdk360.set_rotation(NULL, g_console.screen_orientation);
break;
case MENU_ITEM_RESIZE_MODE:
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;
}
break;
case MENU_ITEM_SCREENSHOT_MODE:
break;
case MENU_ITEM_RESET:
if (g_console.emulator_initialized)
{
return_to_game();
ssnes_game_reset();
}
break;
case MENU_ITEM_RETURN_TO_GAME:
if (g_console.emulator_initialized)
return_to_game();
break;
case MENU_ITEM_RETURN_TO_DASHBOARD:
return_to_dashboard();
break;
}
}
video_xdk360.set_aspect_ratio(NULL, g_console.aspect_ratio_index);
char aspectratio_label[32];
sprintf(aspectratio_label, "Aspect Ratio: %s", g_console.aspect_ratio_name);
unsigned long dwNum = MultiByteToWideChar(CP_ACP, 0, aspectratio_label, -1, NULL, 0);
wchar_t * aspectratio_label_w = new wchar_t[dwNum];
MultiByteToWideChar(CP_ACP, 0, aspectratio_label, -1, aspectratio_label_w, dwNum);
m_quickmenulist.SetText(MENU_ITEM_KEEP_ASPECT_RATIO, aspectratio_label_w);
delete[] aspectratio_label_w;
}
break;
case MENU_ITEM_OVERSCAN_AMOUNT:
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;
}
video_xdk360.set_rotation(NULL, g_console.screen_orientation);
break;
case MENU_ITEM_RESIZE_MODE:
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;
}
break;
case MENU_ITEM_SCREENSHOT_MODE:
break;
case MENU_ITEM_RESET:
if (g_console.emulator_initialized)
{
return_to_game();
ssnes_game_reset();
}
break;
case MENU_ITEM_RETURN_TO_GAME:
if (g_console.emulator_initialized)
return_to_game();
break;
case MENU_ITEM_RETURN_TO_DASHBOARD:
return_to_dashboard();
break;
}
}
if ( hObjPressed == m_back )
NavigateBack(app.hMainScene);
if ( hObjPressed == m_back )
NavigateBack(app.hMainScene);
bHandled = TRUE;
return S_OK;
bHandled = TRUE;
return S_OK;
}
HRESULT CSSNESMain::OnInit(XUIMessageInit * pInitData, BOOL& bHandled)
{
struct retro_system_info info;
retro_get_system_info(&info);
const char *id = info.library_name ? info.library_name : "Unknown";
struct retro_system_info info;
retro_get_system_info(&info);
const char *id = info.library_name ? info.library_name : "Unknown";
GetChildById(L"XuiBtnRomBrowser", &m_filebrowser);
GetChildById(L"XuiBtnSettings", &m_settings);
GetChildById(L"XuiBtnQuickMenu", &m_quick_menu);
GetChildById(L"XuiBtnControls", &m_controls);
GetChildById(L"XuiBtnQuit", &m_quit);
GetChildById(L"XuiTxtTitle", &m_title);
GetChildById(L"XuiTxtCoreText", &m_core);
GetChildById(L"XuiBtnLibsnesCore", &m_change_libsnes_core);
GetChildById(L"XuiBtnRomBrowser", &m_filebrowser);
GetChildById(L"XuiBtnSettings", &m_settings);
GetChildById(L"XuiBtnQuickMenu", &m_quick_menu);
GetChildById(L"XuiBtnControls", &m_controls);
GetChildById(L"XuiBtnQuit", &m_quit);
GetChildById(L"XuiTxtTitle", &m_title);
GetChildById(L"XuiTxtCoreText", &m_core);
GetChildById(L"XuiBtnLibsnesCore", &m_change_libsnes_core);
char core_text[256];
sprintf(core_text, "%s (v%s)", id, info.library_version);
char package_version[32];
sprintf(package_version, "SSNES %s", PACKAGE_VERSION);
unsigned long dwNum = MultiByteToWideChar(CP_ACP, 0, core_text, -1, NULL, 0);
unsigned long dwNum_package = MultiByteToWideChar(CP_ACP, 0, package_version, -1, NULL, 0);
wchar_t * core_text_utf = new wchar_t[dwNum];
wchar_t * package_version_utf = new wchar_t[dwNum_package];
MultiByteToWideChar(CP_ACP, 0, core_text, -1, core_text_utf, dwNum);
MultiByteToWideChar(CP_ACP, 0, package_version, -1, package_version_utf, dwNum_package);
m_core.SetText(core_text_utf);
m_title.SetText(package_version_utf);
delete []core_text_utf;
delete []package_version_utf;
char core_text[256];
sprintf(core_text, "%s (v%s)", id, info.library_version);
char package_version[32];
sprintf(package_version, "SSNES %s", PACKAGE_VERSION);
unsigned long dwNum = MultiByteToWideChar(CP_ACP, 0, core_text, -1, NULL, 0);
unsigned long dwNum_package = MultiByteToWideChar(CP_ACP, 0, package_version, -1, NULL, 0);
wchar_t * core_text_utf = new wchar_t[dwNum];
wchar_t * package_version_utf = new wchar_t[dwNum_package];
MultiByteToWideChar(CP_ACP, 0, core_text, -1, core_text_utf, dwNum);
MultiByteToWideChar(CP_ACP, 0, package_version, -1, package_version_utf, dwNum_package);
m_core.SetText(core_text_utf);
m_title.SetText(package_version_utf);
delete []core_text_utf;
delete []package_version_utf;
return S_OK;
return S_OK;
}
HRESULT CSSNESFileBrowser::OnNotifyPress( HXUIOBJ hObjPressed, BOOL& bHandled )
{
char path[MAX_PATH_LENGTH];
char path[MAX_PATH_LENGTH];
if(hObjPressed == m_romlist)
{
int index = m_romlist.GetCurSel();
if(browser.cur[index].d_type != FILE_ATTRIBUTE_DIRECTORY)
{
memset(strbuffer, 0, sizeof(strbuffer));
wcstombs(strbuffer, (const wchar_t *)m_romlist.GetText(index), sizeof(strbuffer));
if((strstr(strbuffer, ".zip") || strstr(strbuffer, ".ZIP")) && !g_console.block_zip_extract)
{
char path_tmp[1024];
sprintf(path_tmp, "%s\\%s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(browser), strbuffer);
ssnes_extract_zipfile(path_tmp);
}
else
{
memset(g_console.rom_path, 0, sizeof(g_console.rom_path));
sprintf(g_console.rom_path, "%s\\%s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(browser), strbuffer);
return_to_game();
g_console.initialize_ssnes_enable = 1;
}
}
else if(browser.cur[index].d_type == FILE_ATTRIBUTE_DIRECTORY)
{
memset(strbuffer, 0, sizeof(strbuffer));
wcstombs(strbuffer, (const wchar_t *)m_romlist.GetText(index), sizeof(strbuffer));
snprintf(path, sizeof(path), "%s\\%s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(browser), strbuffer);
filebrowser_fetch_directory_entries(path, &browser, &m_romlist, &m_rompathtitle);
}
}
else if (hObjPressed == m_dir_game)
{
filebrowser_new(&browser, g_console.default_rom_startup_dir, ssnes_console_get_rom_ext());
filebrowser_fetch_directory_entries(g_console.default_rom_startup_dir, &browser, &m_romlist, &m_rompathtitle);
}
else if (hObjPressed == m_dir_cache)
{
filebrowser_new(&browser, "cache:", ssnes_console_get_rom_ext());
filebrowser_fetch_directory_entries("cache:", &browser, &m_romlist, &m_rompathtitle);
}
else if(hObjPressed == m_back)
NavigateBack(app.hMainScene);
if(hObjPressed == m_romlist)
{
int index = m_romlist.GetCurSel();
if(browser.cur[index].d_type != FILE_ATTRIBUTE_DIRECTORY)
{
memset(strbuffer, 0, sizeof(strbuffer));
wcstombs(strbuffer, (const wchar_t *)m_romlist.GetText(index), sizeof(strbuffer));
if((strstr(strbuffer, ".zip") || strstr(strbuffer, ".ZIP")) && !g_console.block_zip_extract)
{
char path_tmp[1024];
sprintf(path_tmp, "%s\\%s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(browser), strbuffer);
ssnes_extract_zipfile(path_tmp);
}
else
{
memset(g_console.rom_path, 0, sizeof(g_console.rom_path));
sprintf(g_console.rom_path, "%s\\%s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(browser), strbuffer);
return_to_game();
g_console.initialize_ssnes_enable = 1;
}
}
else if(browser.cur[index].d_type == FILE_ATTRIBUTE_DIRECTORY)
{
memset(strbuffer, 0, sizeof(strbuffer));
wcstombs(strbuffer, (const wchar_t *)m_romlist.GetText(index), sizeof(strbuffer));
snprintf(path, sizeof(path), "%s\\%s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(browser), strbuffer);
filebrowser_fetch_directory_entries(path, &browser, &m_romlist, &m_rompathtitle);
}
}
else if (hObjPressed == m_dir_game)
{
filebrowser_new(&browser, g_console.default_rom_startup_dir, ssnes_console_get_rom_ext());
filebrowser_fetch_directory_entries(g_console.default_rom_startup_dir, &browser, &m_romlist, &m_rompathtitle);
}
else if (hObjPressed == m_dir_cache)
{
filebrowser_new(&browser, "cache:", ssnes_console_get_rom_ext());
filebrowser_fetch_directory_entries("cache:", &browser, &m_romlist, &m_rompathtitle);
}
else if(hObjPressed == m_back)
NavigateBack(app.hMainScene);
bHandled = TRUE;
return S_OK;
bHandled = TRUE;
return S_OK;
}
HRESULT CSSNESCoreBrowser::OnNotifyPress( HXUIOBJ hObjPressed, BOOL& bHandled )
{
char path[MAX_PATH_LENGTH];
char path[MAX_PATH_LENGTH];
if(hObjPressed == m_romlist)
{
int index = m_romlist.GetCurSel();
if(browser.cur[index].d_type != FILE_ATTRIBUTE_DIRECTORY)
{
memset(strbuffer, 0, sizeof(strbuffer));
wcstombs(strbuffer, (const wchar_t *)m_romlist.GetText(index), sizeof(strbuffer));
sprintf(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;
}
else if(tmp_browser.cur[index].d_type == FILE_ATTRIBUTE_DIRECTORY)
{
memset(strbuffer, 0, sizeof(strbuffer));
wcstombs(strbuffer, (const wchar_t *)m_romlist.GetText(index), sizeof(strbuffer));
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);
}
}
else if(hObjPressed == m_back)
NavigateBack(app.hMainScene);
if(hObjPressed == m_romlist)
{
int index = m_romlist.GetCurSel();
if(browser.cur[index].d_type != FILE_ATTRIBUTE_DIRECTORY)
{
memset(strbuffer, 0, sizeof(strbuffer));
wcstombs(strbuffer, (const wchar_t *)m_romlist.GetText(index), sizeof(strbuffer));
sprintf(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;
}
else if(tmp_browser.cur[index].d_type == FILE_ATTRIBUTE_DIRECTORY)
{
memset(strbuffer, 0, sizeof(strbuffer));
wcstombs(strbuffer, (const wchar_t *)m_romlist.GetText(index), sizeof(strbuffer));
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);
}
}
else if(hObjPressed == m_back)
NavigateBack(app.hMainScene);
bHandled = TRUE;
return S_OK;
bHandled = TRUE;
return S_OK;
}
HRESULT CSSNESSettings::OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled )
{
int current_index;
int current_index;
if ( hObjPressed == m_settingslist)
{
current_index = m_settingslist.GetCurSel();
if ( hObjPressed == m_settingslist)
{
current_index = m_settingslist.GetCurSel();
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");
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");
break;
case SETTING_HARDWARE_FILTERING:
g_settings.video.smooth = !g_settings.video.smooth;
m_settingslist.SetText(SETTING_HARDWARE_FILTERING, set_filter_element(g_settings.video.smooth));
break;
}
}
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");
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");
break;
case SETTING_HARDWARE_FILTERING:
g_settings.video.smooth = !g_settings.video.smooth;
m_settingslist.SetText(SETTING_HARDWARE_FILTERING, set_filter_element(g_settings.video.smooth));
break;
}
}
if ( hObjPressed == m_back )
NavigateBack(app.hMainScene);
if ( hObjPressed == m_back )
NavigateBack(app.hMainScene);
bHandled = TRUE;
return S_OK;
bHandled = TRUE;
return S_OK;
}
HRESULT CSSNESMain::OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled )
{
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
bool hdmenus_allowed = vid->video_mode.fIsHiDef && (g_console.aspect_ratio_index >= ASPECT_RATIO_16_9);
bool hdmenus_allowed = vid->video_mode.fIsHiDef && (g_console.aspect_ratio_index >= ASPECT_RATIO_16_9);
HRESULT hr;
HRESULT hr;
if ( hObjPressed == m_filebrowser )
{
hr = XuiSceneCreate(hdmenus_allowed ? L"file://game:/media/hd/" : L"file://game:/media/sd/", L"ssnes_filebrowser.xur", NULL, &app.hFileBrowser);
if (FAILED(hr))
{
SSNES_ERR("Failed to load scene.\n");
}
if ( hObjPressed == m_filebrowser )
{
hr = XuiSceneCreate(hdmenus_allowed ? L"file://game:/media/hd/" : L"file://game:/media/sd/", L"ssnes_filebrowser.xur", NULL, &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"ssnes_quickmenu.xur", NULL, &app.hQuickMenu);
if (FAILED(hr))
SSNES_ERR("Failed to load scene.\n");
if (FAILED(hr))
{
SSNES_ERR("Failed to load scene.\n");
}
NavigateForward(app.hQuickMenu);
}
else if ( hObjPressed == m_change_libsnes_core )
{
hr = XuiSceneCreate(hdmenus_allowed ? L"file://game:/media/hd/" : L"file://game:/media/sd/", L"ssnes_libsnescore_browser.xur", NULL, &app.hCoreBrowser);
if (FAILED(hr))
{
SSNES_ERR("Failed to load scene.\n");
}
NavigateForward(app.hCoreBrowser);
}
else if ( hObjPressed == m_settings )
{
hr = XuiSceneCreate(hdmenus_allowed ? L"file://game:/media/hd/" : L"file://game:/media/sd/", L"ssnes_settings.xur", NULL, &app.hSSNESSettings);
if (FAILED(hr))
SSNES_ERR("Failed to load scene.\n");
NavigateForward(app.hFileBrowser);
}
else if ( hObjPressed == m_quick_menu)
{
hr = XuiSceneCreate(hdmenus_allowed ? L"file://game:/media/hd/" : L"file://game:/media/sd/", L"ssnes_quickmenu.xur", NULL, &app.hQuickMenu);
NavigateForward(app.hSSNESSettings);
}
else if ( hObjPressed == m_quit )
return_to_dashboard();
if (FAILED(hr))
SSNES_ERR("Failed to load scene.\n");
bHandled = TRUE;
return S_OK;
NavigateForward(app.hQuickMenu);
}
else if ( hObjPressed == m_change_libsnes_core )
{
hr = XuiSceneCreate(hdmenus_allowed ? L"file://game:/media/hd/" : L"file://game:/media/sd/", L"ssnes_libsnescore_browser.xur", NULL, &app.hCoreBrowser);
if (FAILED(hr))
{
SSNES_ERR("Failed to load scene.\n");
}
NavigateForward(app.hCoreBrowser);
}
else if ( hObjPressed == m_settings )
{
hr = XuiSceneCreate(hdmenus_allowed ? L"file://game:/media/hd/" : L"file://game:/media/sd/", L"ssnes_settings.xur", NULL, &app.hSSNESSettings);
if (FAILED(hr))
SSNES_ERR("Failed to load scene.\n");
NavigateForward(app.hSSNESSettings);
}
else if ( hObjPressed == m_quit )
return_to_dashboard();
bHandled = TRUE;
return S_OK;
}
int menu_init (void)
{
HRESULT hr;
HRESULT hr;
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
hr = app.InitShared(vid->xdk360_render_device, &vid->d3dpp, XuiPNGTextureLoader);
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
if (FAILED(hr))
{
SSNES_ERR("Failed initializing XUI application.\n");
return 1;
}
hr = app.InitShared(vid->xdk360_render_device, &vid->d3dpp, XuiPNGTextureLoader);
/* Register font */
hr = app.RegisterDefaultTypeface(L"Arial Unicode MS", L"file://game:/media/ssnes.ttf" );
if (FAILED(hr))
{
SSNES_ERR("Failed to register default typeface.\n");
return 1;
}
if (FAILED(hr))
{
SSNES_ERR("Failed initializing XUI application.\n");
return 1;
}
hr = app.LoadSkin( L"file://game:/media/ssnes_scene_skin.xur");
if (FAILED(hr))
{
SSNES_ERR("Failed to load skin.\n");
return 1;
}
/* Register font */
hr = app.RegisterDefaultTypeface(L"Arial Unicode MS", L"file://game:/media/ssnes.ttf" );
if (FAILED(hr))
{
SSNES_ERR("Failed to register default typeface.\n");
return 1;
}
hr = XuiSceneCreate(L"file://game:/media/sd/", L"ssnes_main.xur", NULL, &app.hMainScene);
if (FAILED(hr))
{
SSNES_ERR("Failed to create scene 'ssnes_main.xur'.\n");
return 1;
}
hr = app.LoadSkin( L"file://game:/media/ssnes_scene_skin.xur");
if (FAILED(hr))
{
SSNES_ERR("Failed to load skin.\n");
return 1;
}
XuiSceneNavigateFirst(app.GetRootObj(), app.hMainScene, XUSER_INDEX_FOCUS);
hr = XuiSceneCreate(L"file://game:/media/sd/", L"ssnes_main.xur", NULL, &app.hMainScene);
if (FAILED(hr))
{
SSNES_ERR("Failed to create scene 'ssnes_main.xur'.\n");
return 1;
}
filebrowser_new(&browser, g_console.default_rom_startup_dir, ssnes_console_get_rom_ext());
XuiSceneNavigateFirst(app.GetRootObj(), app.hMainScene, XUSER_INDEX_FOCUS);
return 0;
filebrowser_new(&browser, g_console.default_rom_startup_dir, ssnes_console_get_rom_ext());
return 0;
}
void menu_loop(void)
{
g_console.menu_enable = true;
g_console.menu_enable = true;
HRESULT hr;
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
HRESULT hr;
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
if(g_console.emulator_initialized)
video_xdk360.set_swap_block_state(NULL, true);
if(g_console.emulator_initialized)
video_xdk360.set_swap_block_state(NULL, true);
do
{
g_frame_count++;
if(g_console.emulator_initialized)
{
ssnes_render_cached_frame();
}
else
D3DDevice_Clear(vid->xdk360_render_device, 0, NULL,
D3DCLEAR_TARGET, D3DCOLOR_ARGB(255, 32, 32, 64), 1.0, 0, FALSE);
do
{
g_frame_count++;
if(g_console.emulator_initialized)
{
ssnes_render_cached_frame();
}
else
D3DDevice_Clear(vid->xdk360_render_device, 0, NULL,
D3DCLEAR_TARGET, D3DCOLOR_ARGB(255, 32, 32, 64), 1.0, 0, FALSE);
XINPUT_STATE state;
XInputGetState(0, &state);
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());
g_console.mode_switch = g_console.menu_enable ? MODE_MENU : MODE_EMULATION;
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());
g_console.mode_switch = g_console.menu_enable ? MODE_MENU : MODE_EMULATION;
app.RunFrame(); /* Update XUI */
hr = app.Render(); /* Render XUI */
hr = XuiTimersRun(); /* Update XUI timers */
app.RunFrame(); /* Update XUI */
hr = app.Render(); /* Render XUI */
hr = XuiTimersRun(); /* Update XUI timers */
if(g_console.mode_switch == MODE_EMULATION && !g_console.frame_advance_enable)
{
SET_TIMER_EXPIRATION(30);
}
if(g_console.mode_switch == MODE_EMULATION && !g_console.frame_advance_enable)
{
SET_TIMER_EXPIRATION(30);
}
video_xdk360.swap(NULL);
}while(g_console.menu_enable);
if(g_console.emulator_initialized)
video_xdk360.set_swap_block_state(NULL, false);
video_xdk360.swap(NULL);
}while(g_console.menu_enable);
g_console.ingame_menu_enable = false;
if(g_console.emulator_initialized)
video_xdk360.set_swap_block_state(NULL, false);
g_console.ingame_menu_enable = false;
}

View File

@ -36,20 +36,20 @@ static void xdk360_input_poll(void *data)
for (unsigned i = 0; i < 4; i++)
{
XINPUT_STATE state_tmp;
XINPUT_STATE state_tmp;
unsigned long retval = XInputGetState(i, &state_tmp);
pads_connected += (retval == ERROR_DEVICE_NOT_CONNECTED) ? 0 : 1;
state[i] = state_tmp.Gamepad.wButtons;
state[i] |= ((state_tmp.Gamepad.sThumbLX < -DEADZONE)) << 16;
state[i] |= ((state_tmp.Gamepad.sThumbLX > DEADZONE)) << 17;
state[i] |= ((state_tmp.Gamepad.sThumbLY > DEADZONE)) << 18;
state[i] |= ((state_tmp.Gamepad.sThumbLY < -DEADZONE)) << 19;
state[i] |= ((state_tmp.Gamepad.sThumbRX < -DEADZONE)) << 20;
state[i] |= ((state_tmp.Gamepad.sThumbRX > DEADZONE)) << 21;
state[i] |= ((state_tmp.Gamepad.sThumbRY > DEADZONE)) << 22;
state[i] |= ((state_tmp.Gamepad.sThumbRY < -DEADZONE)) << 23;
state[i] |= ((state_tmp.Gamepad.bLeftTrigger > 128 ? 1 : 0)) << 24;
state[i] |= ((state_tmp.Gamepad.bRightTrigger > 128 ? 1 : 0)) << 25;
pads_connected += (retval == ERROR_DEVICE_NOT_CONNECTED) ? 0 : 1;
state[i] = state_tmp.Gamepad.wButtons;
state[i] |= ((state_tmp.Gamepad.sThumbLX < -DEADZONE)) << 16;
state[i] |= ((state_tmp.Gamepad.sThumbLX > DEADZONE)) << 17;
state[i] |= ((state_tmp.Gamepad.sThumbLY > DEADZONE)) << 18;
state[i] |= ((state_tmp.Gamepad.sThumbLY < -DEADZONE)) << 19;
state[i] |= ((state_tmp.Gamepad.sThumbRX < -DEADZONE)) << 20;
state[i] |= ((state_tmp.Gamepad.sThumbRX > DEADZONE)) << 21;
state[i] |= ((state_tmp.Gamepad.sThumbRY > DEADZONE)) << 22;
state[i] |= ((state_tmp.Gamepad.sThumbRY < -DEADZONE)) << 23;
state[i] |= ((state_tmp.Gamepad.bLeftTrigger > 128 ? 1 : 0)) << 24;
state[i] |= ((state_tmp.Gamepad.bRightTrigger > 128 ? 1 : 0)) << 25;
}
}
@ -77,32 +77,32 @@ static void* xdk360_input_initialize(void)
void xdk360_input_init(void)
{
for(unsigned i = 0; i < 4; i++)
xdk360_input_map_dpad_to_stick(g_settings.input.dpad_emulation[i], i);
xdk360_input_map_dpad_to_stick(g_settings.input.dpad_emulation[i], i);
}
void xdk360_input_map_dpad_to_stick(uint32_t map_dpad_enum, uint32_t controller_id)
{
switch(map_dpad_enum)
{
case DPAD_EMULATION_NONE:
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_UP].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_UP];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_DOWN].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_DOWN];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_LEFT].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_LEFT];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_RIGHT].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_RIGHT];
break;
case DPAD_EMULATION_LSTICK:
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_UP].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_LSTICK_UP_DPAD];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_DOWN].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_LSTICK_DOWN_DPAD];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_LEFT].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_LSTICK_LEFT_DPAD];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_RIGHT].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_LSTICK_RIGHT_DPAD];
break;
case DPAD_EMULATION_RSTICK:
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_UP].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_RSTICK_UP_DPAD];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_DOWN].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_RSTICK_DOWN_DPAD];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_LEFT].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_RSTICK_LEFT_DPAD];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_RIGHT].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_RSTICK_RIGHT_DPAD];
break;
}
switch(map_dpad_enum)
{
case DPAD_EMULATION_NONE:
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_UP].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_UP];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_DOWN].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_DOWN];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_LEFT].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_LEFT];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_RIGHT].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_RIGHT];
break;
case DPAD_EMULATION_LSTICK:
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_UP].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_LSTICK_UP_DPAD];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_DOWN].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_LSTICK_DOWN_DPAD];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_LEFT].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_LSTICK_LEFT_DPAD];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_RIGHT].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_LSTICK_RIGHT_DPAD];
break;
case DPAD_EMULATION_RSTICK:
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_UP].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_RSTICK_UP_DPAD];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_DOWN].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_RSTICK_DOWN_DPAD];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_LEFT].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_RSTICK_LEFT_DPAD];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_RIGHT].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_RSTICK_RIGHT_DPAD];
break;
}
}
static bool xdk360_key_pressed(void *data, int key)
@ -116,45 +116,44 @@ static bool xdk360_key_pressed(void *data, int key)
switch(key)
{
case SSNES_FAST_FORWARD_HOLD_KEY:
return ((state.Gamepad.sThumbRY < -DEADZONE) && !(state.Gamepad.bRightTrigger > 128));
case SSNES_LOAD_STATE_KEY:
return ((state.Gamepad.sThumbRY > DEADZONE) && (state.Gamepad.bRightTrigger > 128));
case SSNES_SAVE_STATE_KEY:
return ((state.Gamepad.sThumbRY < -DEADZONE) && (state.Gamepad.bRightTrigger > 128));
case SSNES_STATE_SLOT_PLUS:
return ((state.Gamepad.sThumbRX > DEADZONE) && (state.Gamepad.bRightTrigger > 128));
case SSNES_STATE_SLOT_MINUS:
return ((state.Gamepad.sThumbRX < -DEADZONE) && (state.Gamepad.bRightTrigger > 128));
case SSNES_FRAMEADVANCE:
if(g_console.frame_advance_enable)
{
g_console.menu_enable = true;
g_console.ingame_menu_enable = true;
g_console.mode_switch = MODE_MENU;
}
return false;
case SSNES_REWIND:
return ((state.Gamepad.sThumbRY > DEADZONE) && !(state.Gamepad.bRightTrigger > 128));
case SSNES_QUIT_KEY:
if(IS_TIMER_EXPIRED())
{
uint32_t left_thumb_pressed = (state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB);
uint32_t right_thumb_pressed = (state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB);
case SSNES_FAST_FORWARD_HOLD_KEY:
return ((state.Gamepad.sThumbRY < -DEADZONE) && !(state.Gamepad.bRightTrigger > 128));
case SSNES_LOAD_STATE_KEY:
return ((state.Gamepad.sThumbRY > DEADZONE) && (state.Gamepad.bRightTrigger > 128));
case SSNES_SAVE_STATE_KEY:
return ((state.Gamepad.sThumbRY < -DEADZONE) && (state.Gamepad.bRightTrigger > 128));
case SSNES_STATE_SLOT_PLUS:
return ((state.Gamepad.sThumbRX > DEADZONE) && (state.Gamepad.bRightTrigger > 128));
case SSNES_STATE_SLOT_MINUS:
return ((state.Gamepad.sThumbRX < -DEADZONE) && (state.Gamepad.bRightTrigger > 128));
case SSNES_FRAMEADVANCE:
if(g_console.frame_advance_enable)
{
g_console.menu_enable = true;
g_console.ingame_menu_enable = true;
g_console.mode_switch = MODE_MENU;
}
return false;
case SSNES_REWIND:
return ((state.Gamepad.sThumbRY > DEADZONE) && !(state.Gamepad.bRightTrigger > 128));
case SSNES_QUIT_KEY:
if(IS_TIMER_EXPIRED())
{
uint32_t left_thumb_pressed = (state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB);
uint32_t right_thumb_pressed = (state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB);
g_console.menu_enable = right_thumb_pressed && left_thumb_pressed && IS_TIMER_EXPIRED();
g_console.ingame_menu_enable = right_thumb_pressed && !left_thumb_pressed;
if(g_console.menu_enable || (g_console.ingame_menu_enable
&& !g_console.menu_enable))
{
g_console.mode_switch = MODE_MENU;
SET_TIMER_EXPIRATION(30);
retval = g_console.menu_enable;
}
g_console.menu_enable = right_thumb_pressed && left_thumb_pressed && IS_TIMER_EXPIRED();
g_console.ingame_menu_enable = right_thumb_pressed && !left_thumb_pressed;
retval = g_console.ingame_menu_enable ? g_console.ingame_menu_enable : g_console.menu_enable;
}
if(g_console.menu_enable || (g_console.ingame_menu_enable && !g_console.menu_enable))
{
g_console.mode_switch = MODE_MENU;
SET_TIMER_EXPIRATION(30);
retval = g_console.menu_enable;
}
retval = g_console.ingame_menu_enable ? g_console.ingame_menu_enable : g_console.menu_enable;
}
}
return retval;

View File

@ -35,13 +35,13 @@ void *g_d3d;
struct hlsl_program_t
{
D3DXHANDLE vid_size_f;
D3DXHANDLE tex_size_f;
D3DXHANDLE out_size_f;
D3DXHANDLE vid_size_v;
D3DXHANDLE tex_size_v;
D3DXHANDLE out_size_v;
XMMATRIX modelViewProj;
D3DXHANDLE vid_size_f;
D3DXHANDLE tex_size_f;
D3DXHANDLE out_size_f;
D3DXHANDLE vid_size_v;
D3DXHANDLE tex_size_v;
D3DXHANDLE out_size_v;
XMMATRIX modelViewProj;
} hlsl_program;
struct XPR_HEADER
@ -212,189 +212,193 @@ static void xdk360_gfx_free(void * data)
static void set_viewport(bool force_full)
{
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
D3DDevice_Clear(vid->xdk360_render_device, 0, NULL, D3DCLEAR_TARGET,
0xff000000, 1.0f, 0, FALSE);
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
D3DDevice_Clear(vid->xdk360_render_device, 0, NULL, D3DCLEAR_TARGET,
0xff000000, 1.0f, 0, FALSE);
int width = vid->video_mode.fIsHiDef ? 1280 : 640;
int height = vid->video_mode.fIsHiDef ? 720 : 480;
int m_viewport_x_temp, m_viewport_y_temp, m_viewport_width_temp, m_viewport_height_temp;
float m_zNear, m_zFar;
int width = vid->video_mode.fIsHiDef ? 1280 : 640;
int height = vid->video_mode.fIsHiDef ? 720 : 480;
int m_viewport_x_temp, m_viewport_y_temp, m_viewport_width_temp, m_viewport_height_temp;
float m_zNear, m_zFar;
m_viewport_x_temp = 0;
m_viewport_y_temp = 0;
m_viewport_width_temp = width;
m_viewport_height_temp = height;
m_viewport_x_temp = 0;
m_viewport_y_temp = 0;
m_viewport_width_temp = width;
m_viewport_height_temp = height;
m_zNear = 0.0f;
m_zFar = 1.0f;
m_zNear = 0.0f;
m_zFar = 1.0f;
if (!force_full)
{
float desired_aspect = g_settings.video.aspect_ratio;
float device_aspect = (float)width / height;
float delta;
if (!force_full)
{
float desired_aspect = g_settings.video.aspect_ratio;
float device_aspect = (float)width / height;
float delta;
// 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)
//{
// m_viewport_x_temp = g_console.custom_viewport_x;
// m_viewport_y_temp = g_console.custom_viewport_y;
// m_viewport_width_temp = g_console.custom_viewport_width;
// m_viewport_height_temp = g_console.custom_viewport_height;
//}
if (device_aspect > desired_aspect)
{
delta = (desired_aspect / device_aspect - 1.0) / 2.0 + 0.5;
m_viewport_x_temp = (int)(width * (0.5 - delta));
m_viewport_width_temp = (int)(2.0 * width * delta);
width = (unsigned)(2.0 * width * delta);
}
else
{
delta = (device_aspect / desired_aspect - 1.0) / 2.0 + 0.5;
m_viewport_y_temp = (int)(height * (0.5 - delta));
m_viewport_height_temp = (int)(2.0 * height * delta);
height = (unsigned)(2.0 * height * delta);
}
}
// 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)
//{
// m_viewport_x_temp = g_console.custom_viewport_x;
// m_viewport_y_temp = g_console.custom_viewport_y;
// m_viewport_width_temp = g_console.custom_viewport_width;
// m_viewport_height_temp = g_console.custom_viewport_height;
//}
if (device_aspect > desired_aspect)
{
delta = (desired_aspect / device_aspect - 1.0) / 2.0 + 0.5;
m_viewport_x_temp = (int)(width * (0.5 - delta));
m_viewport_width_temp = (int)(2.0 * width * delta);
width = (unsigned)(2.0 * width * delta);
}
else
{
delta = (device_aspect / desired_aspect - 1.0) / 2.0 + 0.5;
m_viewport_y_temp = (int)(height * (0.5 - delta));
m_viewport_height_temp = (int)(2.0 * height * delta);
height = (unsigned)(2.0 * height * delta);
}
}
D3DVIEWPORT9 vp = {0};
vp.Width = m_viewport_width_temp;
vp.Height = m_viewport_height_temp;
vp.X = m_viewport_x_temp;
vp.Y = m_viewport_y_temp;
vp.MinZ = m_zNear;
vp.MaxZ = m_zFar;
D3DDevice_SetViewport(vid->xdk360_render_device, &vp);
D3DVIEWPORT9 vp = {0};
vp.Width = m_viewport_width_temp;
vp.Height = m_viewport_height_temp;
vp.X = m_viewport_x_temp;
vp.Y = m_viewport_y_temp;
vp.MinZ = m_zNear;
vp.MaxZ = m_zFar;
D3DDevice_SetViewport(vid->xdk360_render_device, &vp);
//if(gl->overscan_enable && !force_full)
//{
// m_left = -gl->overscan_amount/2;
// m_right = 1 + gl->overscan_amount/2;
// m_bottom = -gl->overscan_amount/2;
//}
//if(gl->overscan_enable && !force_full)
//{
// m_left = -gl->overscan_amount/2;
// m_right = 1 + gl->overscan_amount/2;
// m_bottom = -gl->overscan_amount/2;
//}
}
static void xdk360_set_orientation(void * data, uint32_t orientation)
{
(void)data;
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
FLOAT angle;
(void)data;
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
FLOAT angle;
switch(orientation)
{
case ORIENTATION_NORMAL:
angle = M_PI * 0 / 180;
break;
case ORIENTATION_VERTICAL:
angle = M_PI * 270 / 180;
break;
case ORIENTATION_FLIPPED:
angle = M_PI * 180 / 180;
break;
case ORIENTATION_FLIPPED_ROTATED:
angle = M_PI * 90 / 180;
break;
}
hlsl_program.modelViewProj = XMMatrixRotationZ(angle);
switch(orientation)
{
case ORIENTATION_NORMAL:
angle = M_PI * 0 / 180;
break;
case ORIENTATION_VERTICAL:
angle = M_PI * 270 / 180;
break;
case ORIENTATION_FLIPPED:
angle = M_PI * 180 / 180;
break;
case ORIENTATION_FLIPPED_ROTATED:
angle = M_PI * 90 / 180;
break;
}
hlsl_program.modelViewProj = XMMatrixRotationZ(angle);
}
static void xdk360_set_aspect_ratio(void * data, uint32_t aspectratio_index)
{
(void)data;
switch(aspectratio_index)
{
case ASPECT_RATIO_4_3:
g_settings.video.aspect_ratio = 1.33333333333;
strlcpy(g_console.aspect_ratio_name, "4:3", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_4_4:
g_settings.video.aspect_ratio = 1.0;
strlcpy(g_console.aspect_ratio_name, "4:4", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_4_1:
g_settings.video.aspect_ratio = 4.0;
strlcpy(g_console.aspect_ratio_name, "4:1", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_5_4:
g_settings.video.aspect_ratio = 1.25;
strlcpy(g_console.aspect_ratio_name, "5:4", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_6_5:
g_settings.video.aspect_ratio = 1.2;
strlcpy(g_console.aspect_ratio_name, "6:5", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_7_9:
g_settings.video.aspect_ratio = 0.77777777777;
strlcpy(g_console.aspect_ratio_name, "7:9", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_8_3:
g_settings.video.aspect_ratio = 2.66666666666;
strlcpy(g_console.aspect_ratio_name, "8:3", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_8_7:
g_settings.video.aspect_ratio = 1.14287142857;
strlcpy(g_console.aspect_ratio_name, "8:7", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_16_9:
g_settings.video.aspect_ratio = 1.777778;
strlcpy(g_console.aspect_ratio_name, "16:9", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_16_10:
g_settings.video.aspect_ratio = 1.6;
strlcpy(g_console.aspect_ratio_name, "16:10", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_16_15:
g_settings.video.aspect_ratio = 3.2;
strlcpy(g_console.aspect_ratio_name, "16:15", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_19_12:
g_settings.video.aspect_ratio = 1.58333333333;
strlcpy(g_console.aspect_ratio_name, "19:12", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_19_14:
g_settings.video.aspect_ratio = 1.35714285714;
strlcpy(g_console.aspect_ratio_name, "19:14", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_30_17:
g_settings.video.aspect_ratio = 1.76470588235;
strlcpy(g_console.aspect_ratio_name, "30:17", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_32_9:
g_settings.video.aspect_ratio = 3.55555555555;
strlcpy(g_console.aspect_ratio_name, "32:9", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_2_1:
g_settings.video.aspect_ratio = 2.0;
strlcpy(g_console.aspect_ratio_name, "2:1", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_3_2:
g_settings.video.aspect_ratio = 1.5;
strlcpy(g_console.aspect_ratio_name, "3:2", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_3_4:
g_settings.video.aspect_ratio = 0.75;
strlcpy(g_console.aspect_ratio_name, "3:4", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_1_1:
g_settings.video.aspect_ratio = 1.0;
strlcpy(g_console.aspect_ratio_name, "1:1", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_AUTO:
strlcpy(g_console.aspect_ratio_name, "(Auto)", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_CUSTOM:
strlcpy(g_console.aspect_ratio_name, "(Custom)", sizeof(g_console.aspect_ratio_name));
break;
}
g_settings.video.force_aspect = false;
set_viewport(false);
(void)data;
switch(aspectratio_index)
{
case ASPECT_RATIO_4_3:
g_settings.video.aspect_ratio = 1.33333333333;
strlcpy(g_console.aspect_ratio_name, "4:3", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_4_4:
g_settings.video.aspect_ratio = 1.0;
strlcpy(g_console.aspect_ratio_name, "4:4", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_4_1:
g_settings.video.aspect_ratio = 4.0;
strlcpy(g_console.aspect_ratio_name, "4:1", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_5_4:
g_settings.video.aspect_ratio = 1.25;
strlcpy(g_console.aspect_ratio_name, "5:4", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_6_5:
g_settings.video.aspect_ratio = 1.2;
strlcpy(g_console.aspect_ratio_name, "6:5", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_7_9:
g_settings.video.aspect_ratio = 0.77777777777;
strlcpy(g_console.aspect_ratio_name, "7:9", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_8_3:
g_settings.video.aspect_ratio = 2.66666666666;
strlcpy(g_console.aspect_ratio_name, "8:3", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_8_7:
g_settings.video.aspect_ratio = 1.14287142857;
strlcpy(g_console.aspect_ratio_name, "8:7", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_16_9:
g_settings.video.aspect_ratio = 1.777778;
strlcpy(g_console.aspect_ratio_name, "16:9", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_16_10:
g_settings.video.aspect_ratio = 1.6;
strlcpy(g_console.aspect_ratio_name, "16:10", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_16_15:
g_settings.video.aspect_ratio = 3.2;
strlcpy(g_console.aspect_ratio_name, "16:15", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_19_12:
g_settings.video.aspect_ratio = 1.58333333333;
strlcpy(g_console.aspect_ratio_name, "19:12", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_19_14:
g_settings.video.aspect_ratio = 1.35714285714;
strlcpy(g_console.aspect_ratio_name, "19:14", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_30_17:
g_settings.video.aspect_ratio = 1.76470588235;
strlcpy(g_console.aspect_ratio_name, "30:17", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_32_9:
g_settings.video.aspect_ratio = 3.55555555555;
strlcpy(g_console.aspect_ratio_name, "32:9", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_2_1:
g_settings.video.aspect_ratio = 2.0;
strlcpy(g_console.aspect_ratio_name, "2:1", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_3_2:
g_settings.video.aspect_ratio = 1.5;
strlcpy(g_console.aspect_ratio_name, "3:2", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_3_4:
g_settings.video.aspect_ratio = 0.75;
strlcpy(g_console.aspect_ratio_name, "3:4", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_1_1:
g_settings.video.aspect_ratio = 1.0;
strlcpy(g_console.aspect_ratio_name, "1:1", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_AUTO:
strlcpy(g_console.aspect_ratio_name, "(Auto)", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_CUSTOM:
strlcpy(g_console.aspect_ratio_name, "(Custom)", sizeof(g_console.aspect_ratio_name));
break;
}
g_settings.video.force_aspect = false;
set_viewport(false);
}
static void *xdk360_gfx_init(const video_info_t *video, const input_driver_t **input, void **input_data)
{
HRESULT ret;
HRESULT ret;
if (g_d3d)
return g_d3d;
@ -420,7 +424,7 @@ static void *xdk360_gfx_init(const video_info_t *video, const input_driver_t **i
// no letterboxing in 4:3 mode (if widescreen is
// unsupported
if(!vid->video_mode.fIsWideScreen)
vid->d3dpp.Flags |= D3DPRESENTFLAG_NO_LETTERBOX;
vid->d3dpp.Flags |= D3DPRESENTFLAG_NO_LETTERBOX;
vid->d3dpp.BackBufferWidth = vid->video_mode.fIsHiDef ? 1280 : 640;
vid->d3dpp.BackBufferHeight = vid->video_mode.fIsHiDef ? 720 : 480;
@ -453,31 +457,31 @@ static void *xdk360_gfx_init(const video_info_t *video, const input_driver_t **i
if (SUCCEEDED(ret))
{
SSNES_LOG("Vertex shader program from [%s] successfully compiled.\n", "game:\\media\\shaders\\stock.cg");
ret = D3DXCompileShaderFromFile(
g_settings.video.cg_shader_path, //filepath
NULL, //macros
NULL, //includes
"main_fragment", // main function
"ps_2_0", // shader profile
0, // flags
&pShaderCodeP, // compiled operations
&pErrorMsg, // errors
NULL); // constants
SSNES_LOG("Vertex shader program from [%s] successfully compiled.\n", "game:\\media\\shaders\\stock.cg");
ret = D3DXCompileShaderFromFile(
g_settings.video.cg_shader_path, //filepath
NULL, //macros
NULL, //includes
"main_fragment", // main function
"ps_2_0", // shader profile
0, // flags
&pShaderCodeP, // compiled operations
&pErrorMsg, // errors
NULL); // constants
}
if (FAILED(ret))
{
if(pErrorMsg)
SSNES_LOG("%s\n", (char*)pErrorMsg->GetBufferPointer());
if(pErrorMsg)
SSNES_LOG("%s\n", (char*)pErrorMsg->GetBufferPointer());
D3DDevice_Release(vid->xdk360_render_device);
Direct3D_Release();
Direct3D_Release();
free(vid);
return NULL;
}
else
{
SSNES_LOG("Pixel shader program from [%s] successfully compiled.\n", "game:\\media\\shaders\\stock.cg");
SSNES_LOG("Pixel shader program from [%s] successfully compiled.\n", "game:\\media\\shaders\\stock.cg");
}
vid->pVertexShader = D3DDevice_CreateVertexShader((const DWORD*)pShaderCodeV->GetBufferPointer());
@ -486,7 +490,7 @@ static void *xdk360_gfx_init(const video_info_t *video, const input_driver_t **i
pShaderCodeP->Release();
vid->lpTexture = (D3DTexture*) D3DDevice_CreateTexture(512, 512, 1, 1, 0, D3DFMT_LIN_X1R5G5B5,
0, D3DRTYPE_TEXTURE);
0, D3DRTYPE_TEXTURE);
D3DLOCKED_RECT d3dlr;
D3DTexture_LockRect(vid->lpTexture, 0, &d3dlr, NULL, D3DLOCK_NOSYSLOCK);
@ -549,23 +553,23 @@ static bool xdk360_gfx_frame(void *data, const void *frame,
{
D3DLOCKED_RECT d3dlr;
D3DTexture_LockRect(vid->lpTexture, 0, &d3dlr, NULL, D3DLOCK_NOSYSLOCK);
memset(d3dlr.pBits, 0, 512 * d3dlr.Pitch);
D3DTexture_UnlockRect(vid->lpTexture, 0);
D3DTexture_LockRect(vid->lpTexture, 0, &d3dlr, NULL, D3DLOCK_NOSYSLOCK);
memset(d3dlr.pBits, 0, 512 * d3dlr.Pitch);
D3DTexture_UnlockRect(vid->lpTexture, 0);
float tex_w = width / 512.0f;
float tex_h = height / 512.0f;
const DrawVerticeFormats verts[] = {
{ -1.0f, -1.0f, 0.0f, tex_h },
{ 1.0f, -1.0f, tex_w, tex_h },
{ -1.0f, 1.0f, 0.0f, 0.0f },
{ 1.0f, 1.0f, tex_w, 0.0f },
};
void *verts_ptr = (BYTE*)D3DVertexBuffer_Lock(vid->vertex_buf, 0, 0, 0);
memcpy(verts_ptr, verts, sizeof(verts));
D3DVertexBuffer_Unlock(vid->vertex_buf);
const DrawVerticeFormats verts[] = {
{ -1.0f, -1.0f, 0.0f, tex_h },
{ 1.0f, -1.0f, tex_w, tex_h },
{ -1.0f, 1.0f, 0.0f, 0.0f },
{ 1.0f, 1.0f, tex_w, 0.0f },
};
void *verts_ptr = (BYTE*)D3DVertexBuffer_Lock(vid->vertex_buf, 0, 0, 0);
memcpy(verts_ptr, verts, sizeof(verts));
D3DVertexBuffer_Unlock(vid->vertex_buf);
vid->last_width = width;
vid->last_height = height;
@ -579,9 +583,9 @@ static bool xdk360_gfx_frame(void *data, const void *frame,
D3DTexture_LockRect(vid->lpTexture, 0, &d3dlr, NULL, D3DLOCK_NOSYSLOCK);
for (unsigned y = 0; y < height; y++)
{
const uint8_t *in = (const uint8_t*)frame + y * pitch;
uint8_t *out = (uint8_t*)d3dlr.pBits + y * d3dlr.Pitch;
memcpy(out, in, width * sizeof(uint16_t));
const uint8_t *in = (const uint8_t*)frame + y * pitch;
uint8_t *out = (uint8_t*)d3dlr.pBits + y * d3dlr.Pitch;
memcpy(out, in, width * sizeof(uint16_t));
}
D3DTexture_UnlockRect(vid->lpTexture, 0);
@ -601,39 +605,39 @@ static bool xdk360_gfx_frame(void *data, const void *frame,
D3DDevice_DrawVertices(vid->xdk360_render_device, D3DPT_TRIANGLESTRIP, 0, D3DVERTEXCOUNT(D3DPT_TRIANGLESTRIP, 2));
if (msg)
{
if(IS_TIMER_EXPIRED() || g_first_msg)
{
xdk360_console_format(msg);
g_first_msg = 0;
SET_TIMER_EXPIRATION(30);
}
if(IS_TIMER_EXPIRED() || g_first_msg)
{
xdk360_console_format(msg);
g_first_msg = 0;
SET_TIMER_EXPIRATION(30);
}
xdk360_console_draw();
xdk360_console_draw();
}
if(!vid->block_swap)
D3DDevice_Present(vid->xdk360_render_device);
D3DDevice_Present(vid->xdk360_render_device);
return true;
}
static void xdk360_set_swap_block_swap (void * data, bool toggle)
{
(void)data;
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
vid->block_swap = toggle;
(void)data;
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
vid->block_swap = toggle;
if(toggle)
SSNES_LOG("Swap is set to blocked.\n");
else
SSNES_LOG("Swap is set to non-blocked.\n");
if(toggle)
SSNES_LOG("Swap is set to blocked.\n");
else
SSNES_LOG("Swap is set to non-blocked.\n");
}
static void xdk360_swap (void * data)
{
(void)data;
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
D3DDevice_Present(vid->xdk360_render_device);
(void)data;
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
D3DDevice_Present(vid->xdk360_render_device);
}
static void xdk360_gfx_set_nonblock_state(void *data, bool state)
@ -641,9 +645,9 @@ static void xdk360_gfx_set_nonblock_state(void *data, bool state)
xdk360_video_t *vid = (xdk360_video_t*)data;
SSNES_LOG("D3D Vsync => %s\n", state ? "off" : "on");
if(state)
D3DDevice_SetRenderState_PresentInterval(vid->xdk360_render_device, D3DPRESENT_INTERVAL_IMMEDIATE);
D3DDevice_SetRenderState_PresentInterval(vid->xdk360_render_device, D3DPRESENT_INTERVAL_IMMEDIATE);
else
D3DDevice_SetRenderState_PresentInterval(vid->xdk360_render_device, D3DPRESENT_INTERVAL_ONE);
D3DDevice_SetRenderState_PresentInterval(vid->xdk360_render_device, D3DPRESENT_INTERVAL_ONE);
}
static bool xdk360_gfx_alive(void *data)
@ -660,7 +664,7 @@ static bool xdk360_gfx_focus(void *data)
void xdk360_video_set_vsync(bool vsync)
{
xdk360_gfx_set_nonblock_state(g_d3d, vsync);
xdk360_gfx_set_nonblock_state(g_d3d, vsync);
}
// 360 needs a working graphics stack before SSNESeven starts.
@ -670,31 +674,32 @@ void xdk360_video_set_vsync(bool vsync)
// When SSNES wants to free it, it is ignored.
void xdk360_video_init(void)
{
video_info_t video_info = {0};
// Might have to supply correct values here.
video_info.vsync = g_settings.video.vsync;
video_info.force_aspect = false;
video_info.smooth = g_settings.video.smooth;
video_info.input_scale = 2;
video_info_t video_info = {0};
g_d3d = xdk360_gfx_init(&video_info, NULL, NULL);
video_info.vsync = g_settings.video.vsync;
video_info.force_aspect = false;
video_info.smooth = g_settings.video.smooth;
video_info.input_scale = 2;
g_first_msg = true;
g_d3d = xdk360_gfx_init(&video_info, NULL, NULL);
HRESULT hr = xdk360_console_init("game:\\media\\Arial_12.xpr",
0xff000000, 0xffffffff );
if(FAILED(hr))
{
SSNES_ERR("Couldn't create debug console.\n");
}
g_first_msg = true;
HRESULT hr = xdk360_console_init("game:\\media\\Arial_12.xpr",
0xff000000, 0xffffffff );
if(FAILED(hr))
{
SSNES_ERR("Couldn't create debug console.\n");
}
}
void xdk360_video_deinit(void)
{
void *data = g_d3d;
g_d3d = NULL;
xdk360_console_deinit();
xdk360_gfx_free(data);
void *data = g_d3d;
g_d3d = NULL;
xdk360_console_deinit();
xdk360_gfx_free(data);
}
const video_driver_t video_xdk360 = {

View File

@ -71,57 +71,58 @@ const char * path, const char * extensions)
if (strlcpy(path_buf, path, sizeof(path_buf)) >= sizeof(path_buf))
{
error = 1;
error = 1;
goto error;
}
if (strlcat(path_buf, "\\*", sizeof(path_buf)) >= sizeof(path_buf))
{
error = 1;
error = 1;
goto error;
}
hFind = FindFirstFile(path_buf, &ffd);
if (hFind == INVALID_HANDLE_VALUE)
{
error = 1;
error = 1;
goto error;
}
do
{
strcpy(filebrowser->dir[filebrowser->directory_stack_size], path);
bool found_dir = false;
if(!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
char tmp_extensions[512];
strncpy(tmp_extensions, extensions, sizeof(tmp_extensions));
const char * current_extension = filebrowser_get_extension(ffd.cFileName);
bool found_rom = false;
strcpy(filebrowser->dir[filebrowser->directory_stack_size], path);
bool found_dir = false;
if(current_extension)
{
char * pch = strtok(tmp_extensions, "|");
while (pch != NULL)
{
if(strcmp(current_extension, pch) == 0)
{
found_rom = true;
break;
}
pch = strtok(NULL, "|");
}
}
if(!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
char tmp_extensions[512];
strncpy(tmp_extensions, extensions, sizeof(tmp_extensions));
const char * current_extension = filebrowser_get_extension(ffd.cFileName);
bool found_rom = false;
if(!found_rom)
continue;
}
else if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
found_dir = true;
if(current_extension)
{
char * pch = strtok(tmp_extensions, "|");
while (pch != NULL)
{
if(strcmp(current_extension, pch) == 0)
{
found_rom = true;
break;
}
pch = strtok(NULL, "|");
}
}
filebrowser->cur[filebrowser->file_count].d_type = found_dir ? FILE_ATTRIBUTE_DIRECTORY : FILE_ATTRIBUTE_NORMAL;
if(!found_rom)
continue;
}
else if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
found_dir = true;
filebrowser->cur[filebrowser->file_count].d_type = found_dir ? FILE_ATTRIBUTE_DIRECTORY : FILE_ATTRIBUTE_NORMAL;
sprintf(filebrowser->cur[filebrowser->file_count].d_name, ffd.cFileName);
filebrowser->file_count++;
filebrowser->file_count++;
}while (FindNextFile(hFind, &ffd) != 0 && (filebrowser->file_count + 1) < MAX_FILE_LIMIT);
#elif defined(__CELLOS_LV2__)
int fd;
@ -203,7 +204,7 @@ const char * path, const char * extensions)
error:
if(error)
{
SSNES_ERR("Failed to open directory: \"%s\"\n", path);
SSNES_ERR("Failed to open directory: \"%s\"\n", path);
}
#ifdef _XBOX
FindClose(hFind);

View File

@ -56,83 +56,85 @@ static char sendbuf[4096];
static int inet_pton(int af, const char *src, void *dst)
{
if (af != AF_INET)
return -1;
return inet_aton (src, dst);
if (af != AF_INET)
return -1;
return inet_aton (src, dst);
}
#endif
static int if_up_with(int index)
{
(void)index;
(void)index;
#ifdef __CELLOS_LV2__
int timeout_count = 10;
int state;
int ret;
int timeout_count = 10;
int state;
int ret;
ret = cellNetCtlInit();
if (ret < 0)
{
printf("cellNetCtlInit() failed(%x)\n", ret);
return (-1);
}
ret = cellNetCtlInit();
if (ret < 0)
{
printf("cellNetCtlInit() failed(%x)\n", ret);
return (-1);
}
for (;;)
{
ret = cellNetCtlGetState(&state);
if (ret < 0)
{
printf("cellNetCtlGetState() failed(%x)\n", ret);
return (-1);
}
if (state == CELL_NET_CTL_STATE_IPObtained)
break;
sys_timer_usleep(500 * 1000);
timeout_count--;
if (index && timeout_count < 0)
{
printf("if_up_with(%d) timeout\n", index);
return (0);
}
}
for (;;)
{
ret = cellNetCtlGetState(&state);
if (ret < 0)
{
printf("cellNetCtlGetState() failed(%x)\n", ret);
return (-1);
}
if (state == CELL_NET_CTL_STATE_IPObtained)
break;
sys_timer_usleep(500 * 1000);
timeout_count--;
if (index && timeout_count < 0)
{
printf("if_up_with(%d) timeout\n", index);
return (0);
}
}
#endif
sock=socket(AF_INET,SOCK_DGRAM ,0);
sock=socket(AF_INET,SOCK_DGRAM ,0);
target.sin_family = AF_INET;
target.sin_port = htons(PC_DEVELOPMENT_UDP_PORT);
inet_pton(AF_INET, PC_DEVELOPMENT_IP_ADDRESS, &target.sin_addr);
target.sin_family = AF_INET;
target.sin_port = htons(PC_DEVELOPMENT_UDP_PORT);
inet_pton(AF_INET, PC_DEVELOPMENT_IP_ADDRESS, &target.sin_addr);
return (0);
return (0);
}
static int if_down(int sid)
{
(void)sid;
(void)sid;
#ifdef __CELLOS_LV2__
cellNetCtlTerm();
cellNetCtlTerm();
#endif
return (0);
return (0);
}
void logger_init (void)
{
g_sid = if_up_with(1);
g_sid = if_up_with(1);
}
void logger_shutdown (void)
{
if_down(g_sid);
if_down(g_sid);
}
void logger_send(const char *__format,...)
{
va_list args;
va_list args;
va_start(args,__format);
vsnprintf(sendbuf,4000,__format, args);
va_end(args);
va_start(args,__format);
vsnprintf(sendbuf,4000,__format, args);
va_end(args);
int len=strlen(sendbuf);
sendto(sock,sendbuf,len,MSG_DONTWAIT,(struct sockaddr*)&target,sizeof(target));
int len=strlen(sendbuf);
sendto(sock,sendbuf,len,MSG_DONTWAIT,(struct sockaddr*)&target,sizeof(target));
}

View File

@ -33,29 +33,29 @@
typedef struct CtrlMallocArg
{
uint32_t mallocCallCounts;
uint32_t mallocCallCounts;
} CtrlMallocArg;
typedef struct CtrlFreeArg
{
uint32_t freeCallCounts;
uint32_t freeCallCounts;
} CtrlFreeArg;
void *img_malloc(uint32_t size, void * a)
{
CtrlMallocArg *arg;
arg = (CtrlMallocArg *) a;
arg->mallocCallCounts++;
return malloc(size);
CtrlMallocArg *arg;
arg = (CtrlMallocArg *) a;
arg->mallocCallCounts++;
return malloc(size);
}
static int img_free(void *ptr, void * a)
{
CtrlFreeArg *arg;
arg = (CtrlFreeArg *) a;
arg->freeCallCounts++;
free(ptr);
return 0;
CtrlFreeArg *arg;
arg = (CtrlFreeArg *) a;
arg->freeCallCounts++;
free(ptr);
return 0;
}
/*******************************************************************************
@ -64,88 +64,88 @@ static int img_free(void *ptr, void * a)
static bool ps3graphics_load_jpeg(const char * path, struct texture_image *out_img)
{
CtrlMallocArg MallocArg;
CtrlFreeArg FreeArg;
CellJpgDecMainHandle mHandle = NULL;
CellJpgDecSubHandle sHandle = NULL;
CellJpgDecThreadInParam InParam;
CellJpgDecThreadOutParam OutParam;
CellJpgDecSrc src;
CellJpgDecOpnInfo opnInfo;
CellJpgDecInfo info;
CellJpgDecInParam inParam;
CellJpgDecOutParam outParam;
CellJpgDecDataOutInfo dOutInfo;
CellJpgDecDataCtrlParam dCtrlParam;
CtrlMallocArg MallocArg;
CtrlFreeArg FreeArg;
CellJpgDecMainHandle mHandle = NULL;
CellJpgDecSubHandle sHandle = NULL;
CellJpgDecThreadInParam InParam;
CellJpgDecThreadOutParam OutParam;
CellJpgDecSrc src;
CellJpgDecOpnInfo opnInfo;
CellJpgDecInfo info;
CellJpgDecInParam inParam;
CellJpgDecOutParam outParam;
CellJpgDecDataOutInfo dOutInfo;
CellJpgDecDataCtrlParam dCtrlParam;
MallocArg.mallocCallCounts = 0;
FreeArg.freeCallCounts = 0;
InParam.spuThreadEnable = CELL_JPGDEC_SPU_THREAD_ENABLE;
InParam.ppuThreadPriority = 1001;
InParam.spuThreadPriority = 250;
InParam.cbCtrlMallocFunc = img_malloc;
InParam.cbCtrlMallocArg = &MallocArg;
InParam.cbCtrlFreeFunc = img_free;
InParam.cbCtrlFreeArg = &FreeArg;
MallocArg.mallocCallCounts = 0;
FreeArg.freeCallCounts = 0;
InParam.spuThreadEnable = CELL_JPGDEC_SPU_THREAD_ENABLE;
InParam.ppuThreadPriority = 1001;
InParam.spuThreadPriority = 250;
InParam.cbCtrlMallocFunc = img_malloc;
InParam.cbCtrlMallocArg = &MallocArg;
InParam.cbCtrlFreeFunc = img_free;
InParam.cbCtrlFreeArg = &FreeArg;
int ret_jpeg, ret = -1;
ret_jpeg = cellJpgDecCreate(&mHandle, &InParam, &OutParam);
int ret_jpeg, ret = -1;
ret_jpeg = cellJpgDecCreate(&mHandle, &InParam, &OutParam);
if (ret_jpeg != CELL_OK)
goto error;
if (ret_jpeg != CELL_OK)
goto error;
memset(&src, 0, sizeof(CellJpgDecSrc));
src.srcSelect = CELL_JPGDEC_FILE;
src.fileName = path;
src.fileOffset = 0;
src.fileSize = 0;
src.streamPtr = NULL;
src.streamSize = 0;
memset(&src, 0, sizeof(CellJpgDecSrc));
src.srcSelect = CELL_JPGDEC_FILE;
src.fileName = path;
src.fileOffset = 0;
src.fileSize = 0;
src.streamPtr = NULL;
src.streamSize = 0;
src.spuThreadEnable = CELL_JPGDEC_SPU_THREAD_ENABLE;
src.spuThreadEnable = CELL_JPGDEC_SPU_THREAD_ENABLE;
ret = cellJpgDecOpen(mHandle, &sHandle, &src, &opnInfo);
ret = cellJpgDecOpen(mHandle, &sHandle, &src, &opnInfo);
if (ret != CELL_OK)
goto error;
if (ret != CELL_OK)
goto error;
ret = cellJpgDecReadHeader(mHandle, sHandle, &info);
ret = cellJpgDecReadHeader(mHandle, sHandle, &info);
if (ret != CELL_OK)
goto error;
if (ret != CELL_OK)
goto error;
inParam.commandPtr = NULL;
inParam.method = CELL_JPGDEC_FAST;
inParam.outputMode = CELL_JPGDEC_TOP_TO_BOTTOM;
inParam.outputColorSpace = CELL_JPG_ARGB;
inParam.downScale = 1;
inParam.outputColorAlpha = 0xfe;
ret = cellJpgDecSetParameter(mHandle, sHandle, &inParam, &outParam);
inParam.commandPtr = NULL;
inParam.method = CELL_JPGDEC_FAST;
inParam.outputMode = CELL_JPGDEC_TOP_TO_BOTTOM;
inParam.outputColorSpace = CELL_JPG_ARGB;
inParam.downScale = 1;
inParam.outputColorAlpha = 0xfe;
ret = cellJpgDecSetParameter(mHandle, sHandle, &inParam, &outParam);
if (ret != CELL_OK)
goto error;
if (ret != CELL_OK)
goto error;
dCtrlParam.outputBytesPerLine = outParam.outputWidth * 4;
ret = cellJpgDecDecodeData(mHandle, sHandle, (uint8_t*)out_img->pixels, &dCtrlParam, &dOutInfo);
dCtrlParam.outputBytesPerLine = outParam.outputWidth * 4;
ret = cellJpgDecDecodeData(mHandle, sHandle, (uint8_t*)out_img->pixels, &dCtrlParam, &dOutInfo);
if (ret != CELL_OK || dOutInfo.status != CELL_JPGDEC_DEC_STATUS_FINISH)
goto error;
if (ret != CELL_OK || dOutInfo.status != CELL_JPGDEC_DEC_STATUS_FINISH)
goto error;
out_img->width = outParam.outputWidth;
out_img->height = outParam.outputHeight;
out_img->width = outParam.outputWidth;
out_img->height = outParam.outputHeight;
cellJpgDecClose(mHandle, sHandle);
cellJpgDecDestroy(mHandle);
cellJpgDecClose(mHandle, sHandle);
cellJpgDecDestroy(mHandle);
return true;
return true;
error:
SSNES_ERR("ps3graphics_load_jpeg(): error.\n");
if (mHandle && sHandle)
cellJpgDecClose(mHandle, sHandle);
if (mHandle)
cellJpgDecDestroy(mHandle);
return false;
SSNES_ERR("ps3graphics_load_jpeg(): error.\n");
if (mHandle && sHandle)
cellJpgDecClose(mHandle, sHandle);
if (mHandle)
cellJpgDecDestroy(mHandle);
return false;
}
/*******************************************************************************
@ -154,113 +154,113 @@ error:
static bool ps3graphics_load_png(const char * path, struct texture_image *out_img)
{
CtrlMallocArg MallocArg;
CtrlFreeArg FreeArg;
CellPngDecMainHandle mHandle = NULL;
CellPngDecSubHandle sHandle = NULL;
CellPngDecThreadInParam InParam;
CellPngDecThreadOutParam OutParam;
CellPngDecSrc src;
CellPngDecOpnInfo opnInfo;
CellPngDecInfo info;
CellPngDecInParam inParam;
CellPngDecOutParam outParam;
CellPngDecDataOutInfo dOutInfo;
CellPngDecDataCtrlParam dCtrlParam;
CtrlMallocArg MallocArg;
CtrlFreeArg FreeArg;
CellPngDecMainHandle mHandle = NULL;
CellPngDecSubHandle sHandle = NULL;
CellPngDecThreadInParam InParam;
CellPngDecThreadOutParam OutParam;
CellPngDecSrc src;
CellPngDecOpnInfo opnInfo;
CellPngDecInfo info;
CellPngDecInParam inParam;
CellPngDecOutParam outParam;
CellPngDecDataOutInfo dOutInfo;
CellPngDecDataCtrlParam dCtrlParam;
MallocArg.mallocCallCounts = 0;
FreeArg.freeCallCounts = 0;
InParam.spuThreadEnable = CELL_PNGDEC_SPU_THREAD_ENABLE;
InParam.ppuThreadPriority = 512;
InParam.spuThreadPriority = 200;
InParam.cbCtrlMallocFunc = img_malloc;
InParam.cbCtrlMallocArg = &MallocArg;
InParam.cbCtrlFreeFunc = img_free;
InParam.cbCtrlFreeArg = &FreeArg;
MallocArg.mallocCallCounts = 0;
FreeArg.freeCallCounts = 0;
InParam.spuThreadEnable = CELL_PNGDEC_SPU_THREAD_ENABLE;
InParam.ppuThreadPriority = 512;
InParam.spuThreadPriority = 200;
InParam.cbCtrlMallocFunc = img_malloc;
InParam.cbCtrlMallocArg = &MallocArg;
InParam.cbCtrlFreeFunc = img_free;
InParam.cbCtrlFreeArg = &FreeArg;
int ret_png, ret = -1;
ret_png = cellPngDecCreate(&mHandle, &InParam, &OutParam);
int ret_png, ret = -1;
ret_png = cellPngDecCreate(&mHandle, &InParam, &OutParam);
if (ret_png != CELL_OK)
goto error;
if (ret_png != CELL_OK)
goto error;
memset(&src, 0, sizeof(CellPngDecSrc));
src.srcSelect = CELL_PNGDEC_FILE;
src.fileName = path;
src.fileOffset = 0;
src.fileSize = 0;
src.streamPtr = 0;
src.streamSize = 0;
memset(&src, 0, sizeof(CellPngDecSrc));
src.srcSelect = CELL_PNGDEC_FILE;
src.fileName = path;
src.fileOffset = 0;
src.fileSize = 0;
src.streamPtr = 0;
src.streamSize = 0;
src.spuThreadEnable = CELL_PNGDEC_SPU_THREAD_ENABLE;
src.spuThreadEnable = CELL_PNGDEC_SPU_THREAD_ENABLE;
ret = cellPngDecOpen(mHandle, &sHandle, &src, &opnInfo);
ret = cellPngDecOpen(mHandle, &sHandle, &src, &opnInfo);
if (ret != CELL_OK)
goto error;
ret = cellPngDecReadHeader(mHandle, sHandle, &info);
if (ret != CELL_OK)
goto error;
inParam.commandPtr = NULL;
inParam.outputMode = CELL_PNGDEC_TOP_TO_BOTTOM;
inParam.outputColorSpace = CELL_PNGDEC_ARGB;
inParam.outputBitDepth = 8;
inParam.outputPackFlag = CELL_PNGDEC_1BYTE_PER_1PIXEL;
inParam.outputAlphaSelect = CELL_PNGDEC_STREAM_ALPHA;
ret = cellPngDecSetParameter(mHandle, sHandle, &inParam, &outParam);
if (ret != CELL_OK)
goto error;
dCtrlParam.outputBytesPerLine = outParam.outputWidth * 4;
ret = cellPngDecDecodeData(mHandle, sHandle, (uint8_t*)out_img->pixels, &dCtrlParam, &dOutInfo);
if (ret != CELL_OK)
goto error;
if (ret != CELL_OK || dOutInfo.status != CELL_PNGDEC_DEC_STATUS_FINISH)
goto error;
ret = cellPngDecReadHeader(mHandle, sHandle, &info);
out_img->width = outParam.outputWidth;
out_img->height = outParam.outputHeight;
cellPngDecClose(mHandle, sHandle);
cellPngDecDestroy(mHandle);
if (ret != CELL_OK)
goto error;
inParam.commandPtr = NULL;
inParam.outputMode = CELL_PNGDEC_TOP_TO_BOTTOM;
inParam.outputColorSpace = CELL_PNGDEC_ARGB;
inParam.outputBitDepth = 8;
inParam.outputPackFlag = CELL_PNGDEC_1BYTE_PER_1PIXEL;
inParam.outputAlphaSelect = CELL_PNGDEC_STREAM_ALPHA;
ret = cellPngDecSetParameter(mHandle, sHandle, &inParam, &outParam);
if (ret != CELL_OK)
goto error;
dCtrlParam.outputBytesPerLine = outParam.outputWidth * 4;
ret = cellPngDecDecodeData(mHandle, sHandle, (uint8_t*)out_img->pixels, &dCtrlParam, &dOutInfo);
if (ret != CELL_OK || dOutInfo.status != CELL_PNGDEC_DEC_STATUS_FINISH)
goto error;
out_img->width = outParam.outputWidth;
out_img->height = outParam.outputHeight;
cellPngDecClose(mHandle, sHandle);
cellPngDecDestroy(mHandle);
return true;
return true;
error:
SSNES_ERR("ps3graphics_load_png(): error.\n");
if (mHandle && sHandle)
cellPngDecClose(mHandle, sHandle);
if (mHandle)
cellPngDecDestroy(mHandle);
return false;
SSNES_ERR("ps3graphics_load_png(): error.\n");
if (mHandle && sHandle)
cellPngDecClose(mHandle, sHandle);
if (mHandle)
cellPngDecDestroy(mHandle);
return false;
}
bool texture_image_load(const char *path, struct texture_image *out_img)
{
out_img->pixels = malloc(2048 * 2048 * 4);
memset(out_img->pixels, 0, (2048 * 2048 * 4));
if(strstr(path, ".PNG") != NULL || strstr(path, ".png") != NULL)
{
if (!ps3graphics_load_png(path, out_img))
{
free(out_img->pixels);
return false;
}
}
else
{
if (!ps3graphics_load_jpeg(path, out_img))
{
free(out_img->pixels);
return false;
}
}
out_img->pixels = malloc(2048 * 2048 * 4);
memset(out_img->pixels, 0, (2048 * 2048 * 4));
if(strstr(path, ".PNG") != NULL || strstr(path, ".png") != NULL)
{
if (!ps3graphics_load_png(path, out_img))
{
free(out_img->pixels);
return false;
}
}
else
{
if (!ps3graphics_load_jpeg(path, out_img))
{
free(out_img->pixels);
return false;
}
}
return true;
return true;
}

View File

@ -120,7 +120,7 @@ static int16_t ps3_input_state(void *data, const struct snes_keybind **binds,
ON-SCREEN KEYBOARD UTILITY
============================================================ */
#define OSK_IN_USE (0x00000001)
#define OSK_IN_USE 1
void oskutil_init(oskutil_params *params, unsigned int containersize)
{
@ -265,27 +265,27 @@ void ps3_input_init(void)
void ps3_input_map_dpad_to_stick(uint32_t map_dpad_enum, uint32_t controller_id)
{
switch(map_dpad_enum)
{
case DPAD_EMULATION_NONE:
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_UP].joykey = ssnes_platform_keybind_lut[PS3_DEVICE_ID_JOYPAD_UP];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_DOWN].joykey = ssnes_platform_keybind_lut[PS3_DEVICE_ID_JOYPAD_DOWN];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_LEFT].joykey = ssnes_platform_keybind_lut[PS3_DEVICE_ID_JOYPAD_LEFT];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_RIGHT].joykey = ssnes_platform_keybind_lut[PS3_DEVICE_ID_JOYPAD_RIGHT];
break;
case DPAD_EMULATION_LSTICK:
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_UP].joykey = ssnes_platform_keybind_lut[PS3_DEVICE_ID_LSTICK_UP_DPAD];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_DOWN].joykey = ssnes_platform_keybind_lut[PS3_DEVICE_ID_LSTICK_DOWN_DPAD];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_LEFT].joykey = ssnes_platform_keybind_lut[PS3_DEVICE_ID_LSTICK_LEFT_DPAD];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_RIGHT].joykey = ssnes_platform_keybind_lut[PS3_DEVICE_ID_LSTICK_RIGHT_DPAD];
break;
case DPAD_EMULATION_RSTICK:
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_UP].joykey = ssnes_platform_keybind_lut[PS3_DEVICE_ID_RSTICK_UP_DPAD];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_DOWN].joykey = ssnes_platform_keybind_lut[PS3_DEVICE_ID_RSTICK_DOWN_DPAD];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_LEFT].joykey = ssnes_platform_keybind_lut[PS3_DEVICE_ID_RSTICK_LEFT_DPAD];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_RIGHT].joykey = ssnes_platform_keybind_lut[PS3_DEVICE_ID_RSTICK_RIGHT_DPAD];
break;
}
switch(map_dpad_enum)
{
case DPAD_EMULATION_NONE:
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_UP].joykey = ssnes_platform_keybind_lut[PS3_DEVICE_ID_JOYPAD_UP];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_DOWN].joykey = ssnes_platform_keybind_lut[PS3_DEVICE_ID_JOYPAD_DOWN];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_LEFT].joykey = ssnes_platform_keybind_lut[PS3_DEVICE_ID_JOYPAD_LEFT];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_RIGHT].joykey = ssnes_platform_keybind_lut[PS3_DEVICE_ID_JOYPAD_RIGHT];
break;
case DPAD_EMULATION_LSTICK:
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_UP].joykey = ssnes_platform_keybind_lut[PS3_DEVICE_ID_LSTICK_UP_DPAD];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_DOWN].joykey = ssnes_platform_keybind_lut[PS3_DEVICE_ID_LSTICK_DOWN_DPAD];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_LEFT].joykey = ssnes_platform_keybind_lut[PS3_DEVICE_ID_LSTICK_LEFT_DPAD];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_RIGHT].joykey = ssnes_platform_keybind_lut[PS3_DEVICE_ID_LSTICK_RIGHT_DPAD];
break;
case DPAD_EMULATION_RSTICK:
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_UP].joykey = ssnes_platform_keybind_lut[PS3_DEVICE_ID_RSTICK_UP_DPAD];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_DOWN].joykey = ssnes_platform_keybind_lut[PS3_DEVICE_ID_RSTICK_DOWN_DPAD];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_LEFT].joykey = ssnes_platform_keybind_lut[PS3_DEVICE_ID_RSTICK_LEFT_DPAD];
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_RIGHT].joykey = ssnes_platform_keybind_lut[PS3_DEVICE_ID_RSTICK_RIGHT_DPAD];
break;
}
}
static bool ps3_key_pressed(void *data, int key)
@ -316,21 +316,21 @@ static bool ps3_key_pressed(void *data, int key)
case SSNES_QUIT_KEY:
if(IS_TIMER_EXPIRED(g_console.timer_expiration_frame_count))
{
uint32_t r3_pressed = CTRL_R3(state[0]);
uint32_t l3_pressed = CTRL_L3(state[0]);
bool retval = false;
g_console.menu_enable = (r3_pressed && l3_pressed && IS_TIMER_EXPIRED(g_console.timer_expiration_frame_count));
g_console.ingame_menu_enable = r3_pressed && !l3_pressed;
uint32_t r3_pressed = CTRL_R3(state[0]);
uint32_t l3_pressed = CTRL_L3(state[0]);
bool retval = false;
g_console.menu_enable = (r3_pressed && l3_pressed && IS_TIMER_EXPIRED(g_console.timer_expiration_frame_count));
g_console.ingame_menu_enable = r3_pressed && !l3_pressed;
if(g_console.menu_enable || (g_console.ingame_menu_enable && !g_console.menu_enable))
{
g_console.mode_switch = MODE_MENU;
SET_TIMER_EXPIRATION(g_console.control_timer_expiration_frame_count, 30);
retval = g_console.menu_enable;
}
if(g_console.menu_enable || (g_console.ingame_menu_enable && !g_console.menu_enable))
{
g_console.mode_switch = MODE_MENU;
SET_TIMER_EXPIRATION(g_console.control_timer_expiration_frame_count, 30);
retval = g_console.menu_enable;
}
retval = g_console.ingame_menu_enable ? g_console.ingame_menu_enable : g_console.menu_enable;
return retval;
retval = g_console.ingame_menu_enable ? g_console.ingame_menu_enable : g_console.menu_enable;
return retval;
}
default:
return false;

View File

@ -133,19 +133,19 @@ void ps3_input_map_dpad_to_stick(uint32_t map_dpad_enum, uint32_t controller_id)
typedef struct
{
unsigned int osk_memorycontainer;
wchar_t init_message[CELL_OSKDIALOG_STRING_SIZE + 1];
wchar_t message[CELL_OSKDIALOG_STRING_SIZE + 1];
wchar_t osk_text_buffer[CELL_OSKDIALOG_STRING_SIZE + 1];
char osk_text_buffer_char[CELL_OSKDIALOG_STRING_SIZE + 1];
uint32_t flags;
bool is_running;
bool text_can_be_fetched;
sys_memory_container_t containerid;
CellOskDialogPoint pos;
CellOskDialogInputFieldInfo inputFieldInfo;
CellOskDialogCallbackReturnParam outputInfo;
CellOskDialogParam dialogParam;
unsigned int osk_memorycontainer;
wchar_t init_message[CELL_OSKDIALOG_STRING_SIZE + 1];
wchar_t message[CELL_OSKDIALOG_STRING_SIZE + 1];
wchar_t osk_text_buffer[CELL_OSKDIALOG_STRING_SIZE + 1];
char osk_text_buffer_char[CELL_OSKDIALOG_STRING_SIZE + 1];
uint32_t flags;
bool is_running;
bool text_can_be_fetched;
sys_memory_container_t containerid;
CellOskDialogPoint pos;
CellOskDialogInputFieldInfo inputFieldInfo;
CellOskDialogCallbackReturnParam outputInfo;
CellOskDialogParam dialogParam;
} oskutil_params;
void oskutil_write_message(oskutil_params *params, const wchar_t* msg);

File diff suppressed because it is too large Load Diff

View File

@ -67,281 +67,284 @@ SYS_PROCESS_PARAM(1001, 0x100000)
static bool path_file_exists(const char *path)
{
FILE *dummy = fopen(path, "rb");
if (dummy)
{
fclose(dummy);
return true;
}
return false;
FILE *dummy = fopen(path, "rb");
if (dummy)
{
fclose(dummy);
return true;
}
return false;
}
static void dir_list_free(char **dir_list)
{
if (!dir_list)
return;
if (!dir_list)
return;
char **orig = dir_list;
while (*dir_list)
free(*dir_list++);
free(orig);
char **orig = dir_list;
while (*dir_list)
free(*dir_list++);
free(orig);
}
static char **dir_list_new(const char *dir, const char *ext)
{
size_t cur_ptr = 0;
size_t cur_size = 32;
char **dir_list = NULL;
size_t cur_ptr = 0;
size_t cur_size = 32;
char **dir_list = NULL;
DIR *directory = NULL;
const struct dirent *entry = NULL;
DIR *directory = NULL;
const struct dirent *entry = NULL;
directory = opendir(dir);
if (!directory)
goto error;
directory = opendir(dir);
if (!directory)
goto error;
dir_list = (char**)calloc(cur_size, sizeof(char*));
if (!dir_list)
goto error;
dir_list = (char**)calloc(cur_size, sizeof(char*));
if (!dir_list)
goto error;
while ((entry = readdir(directory)))
{
// Not a perfect search of course, but hopefully good enough in practice.
if (ext && !strstr(entry->d_name, ext))
continue;
while ((entry = readdir(directory)))
{
// Not a perfect search of course, but hopefully good enough in practice.
if (ext && !strstr(entry->d_name, ext))
continue;
dir_list[cur_ptr] = (char*)malloc(PATH_MAX);
if (!dir_list[cur_ptr])
goto error;
dir_list[cur_ptr] = (char*)malloc(PATH_MAX);
if (!dir_list[cur_ptr])
goto error;
strlcpy(dir_list[cur_ptr], dir, PATH_MAX);
strlcat(dir_list[cur_ptr], "/", PATH_MAX);
strlcat(dir_list[cur_ptr], entry->d_name, PATH_MAX);
strlcpy(dir_list[cur_ptr], dir, PATH_MAX);
strlcat(dir_list[cur_ptr], "/", PATH_MAX);
strlcat(dir_list[cur_ptr], entry->d_name, PATH_MAX);
cur_ptr++;
if (cur_ptr + 1 == cur_size) // Need to reserve for NULL.
{
cur_size *= 2;
dir_list = (char**)realloc(dir_list, cur_size * sizeof(char*));
if (!dir_list)
goto error;
cur_ptr++;
if (cur_ptr + 1 == cur_size) // Need to reserve for NULL.
{
cur_size *= 2;
dir_list = (char**)realloc(dir_list, cur_size * sizeof(char*));
if (!dir_list)
goto error;
// Make sure it's all NULL'd out since we cannot rely on realloc to do this.
memset(dir_list + cur_ptr, 0, (cur_size - cur_ptr) * sizeof(char*));
}
}
// Make sure it's all NULL'd out since we cannot rely on realloc to do this.
memset(dir_list + cur_ptr, 0, (cur_size - cur_ptr) * sizeof(char*));
}
}
closedir(directory);
return dir_list;
closedir(directory);
return dir_list;
error:
SSNES_ERR("Failed to open directory: \"%s\"\n", dir);
if (directory)
closedir(directory);
dir_list_free(dir_list);
return NULL;
SSNES_ERR("Failed to open directory: \"%s\"\n", dir);
if (directory)
closedir(directory);
dir_list_free(dir_list);
return NULL;
}
static void find_and_set_first_file(void)
{
//Last fallback - we'll need to start the first .SELF file
// we can find in the SSNES cores directory
char ** dir_list = dir_list_new(LIBSNES_DIR_PATH, ".SELF");
if (!dir_list)
{
SSNES_ERR("Failed last fallback - SSNES Salamander will exit.\n");
return;
}
//Last fallback - we'll need to start the first .SELF file
// we can find in the SSNES cores directory
const char * first_self = dir_list[0];
char ** dir_list = dir_list_new(LIBSNES_DIR_PATH, ".SELF");
if (!dir_list)
{
SSNES_ERR("Failed last fallback - SSNES Salamander will exit.\n");
return;
}
if(first_self)
{
SSNES_LOG("Start first entry in libretro cores dir: [%s].\n", first_self);
strlcpy(libretro_path, first_self, sizeof(libretro_path));
}
else
{
SSNES_ERR("Failed last fallback - SSNES Salamander will exit.\n");
}
const char * first_self = dir_list[0];
dir_list_free(dir_list);
if(first_self)
{
SSNES_LOG("Start first entry in libretro cores dir: [%s].\n", first_self);
strlcpy(libretro_path, first_self, sizeof(libretro_path));
}
else
{
SSNES_ERR("Failed last fallback - SSNES Salamander will exit.\n");
}
dir_list_free(dir_list);
}
static void init_settings(void)
{
char tmp_str[MAX_PATH_LENGTH];
bool config_file_exists;
char tmp_str[MAX_PATH_LENGTH];
bool config_file_exists;
if(!path_file_exists(SYS_CONFIG_FILE))
{
config_file_exists = false;
SSNES_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_exists = true;
if(!path_file_exists(SYS_CONFIG_FILE))
{
FILE * f;
config_file_exists = false;
SSNES_ERR("Config file \"%s\" doesn't exist. Creating...\n", SYS_CONFIG_FILE);
f = fopen(SYS_CONFIG_FILE, "w");
fclose(f);
}
else
config_file_exists = true;
//try to find CORE.SELF
char core_self[1024];
snprintf(core_self, sizeof(core_self), "%s/CORE.SELF", LIBSNES_DIR_PATH);
//try to find CORE.SELF
char core_self[1024];
snprintf(core_self, sizeof(core_self), "%s/CORE.SELF", LIBSNES_DIR_PATH);
if(path_file_exists(core_self))
{
//Start CORE.SELF
snprintf(libretro_path, sizeof(libretro_path), core_self);
SSNES_LOG("Start [%s].\n", libretro_path);
}
else
{
if(config_file_exists)
{
config_file_t * conf = config_file_new(SYS_CONFIG_FILE);
config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str));
snprintf(libretro_path, sizeof(libretro_path), tmp_str);
}
if(path_file_exists(core_self))
{
//Start CORE.SELF
snprintf(libretro_path, sizeof(libretro_path), core_self);
SSNES_LOG("Start [%s].\n", libretro_path);
}
else
{
if(config_file_exists)
{
config_file_t * conf = config_file_new(SYS_CONFIG_FILE);
config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str));
snprintf(libretro_path, sizeof(libretro_path), tmp_str);
}
if(!config_file_exists || !strcmp(libretro_path, ""))
find_and_set_first_file();
else
{
SSNES_LOG("Start [%s] found in ssnes.cfg.\n", libretro_path);
}
}
if(!config_file_exists || !strcmp(libretro_path, ""))
find_and_set_first_file();
else
{
SSNES_LOG("Start [%s] found in ssnes.cfg.\n", libretro_path);
}
}
}
static void get_environment_settings (void)
{
unsigned int get_type;
unsigned int get_attributes;
CellGameContentSize size;
char dirName[CELL_GAME_DIRNAME_SIZE];
unsigned int get_type;
unsigned int get_attributes;
CellGameContentSize size;
char dirName[CELL_GAME_DIRNAME_SIZE];
memset(&size, 0x00, sizeof(CellGameContentSize));
memset(&size, 0x00, sizeof(CellGameContentSize));
int ret = cellGameBootCheck(&get_type, &get_attributes, &size, dirName);
if(ret < 0)
{
SSNES_ERR("cellGameBootCheck() Error: 0x%x.\n", ret);
}
else
{
SSNES_LOG("cellGameBootCheck() OK.\n");
SSNES_LOG("Directory name: [%s].\n", dirName);
SSNES_LOG(" HDD Free Size (in KB) = [%d] Size (in KB) = [%d] System Size (in KB) = [%d].\n", size.hddFreeSizeKB, size.sizeKB, size.sysSizeKB);
int ret = cellGameBootCheck(&get_type, &get_attributes, &size, dirName);
if(ret < 0)
{
SSNES_ERR("cellGameBootCheck() Error: 0x%x.\n", ret);
}
else
{
SSNES_LOG("cellGameBootCheck() OK.\n");
SSNES_LOG("Directory name: [%s].\n", dirName);
SSNES_LOG(" HDD Free Size (in KB) = [%d] Size (in KB) = [%d] System Size (in KB) = [%d].\n", size.hddFreeSizeKB, size.sizeKB, size.sysSizeKB);
switch(get_type)
{
case CELL_GAME_GAMETYPE_DISC:
SSNES_LOG("SSNES was launched on Optical Disc Drive.\n");
break;
case CELL_GAME_GAMETYPE_HDD:
SSNES_LOG("SSNES was launched on HDD.\n");
break;
}
switch(get_type)
{
case CELL_GAME_GAMETYPE_DISC:
SSNES_LOG("SSNES was launched on Optical Disc Drive.\n");
break;
case CELL_GAME_GAMETYPE_HDD:
SSNES_LOG("SSNES was launched on HDD.\n");
break;
}
if((get_attributes & CELL_GAME_ATTRIBUTE_APP_HOME) == CELL_GAME_ATTRIBUTE_APP_HOME)
SSNES_LOG("SSNES was launched from host machine (APP_HOME).\n");
if((get_attributes & CELL_GAME_ATTRIBUTE_APP_HOME) == CELL_GAME_ATTRIBUTE_APP_HOME)
SSNES_LOG("SSNES was launched from host machine (APP_HOME).\n");
ret = cellGameContentPermit(contentInfoPath, usrDirPath);
ret = cellGameContentPermit(contentInfoPath, usrDirPath);
if(ret < 0)
{
SSNES_ERR("cellGameContentPermit() Error: 0x%x\n", ret);
}
else
{
SSNES_LOG("cellGameContentPermit() OK.\n");
SSNES_LOG("contentInfoPath : [%s].\n", contentInfoPath);
SSNES_LOG("usrDirPath : [%s].\n", usrDirPath);
}
if(ret < 0)
{
SSNES_ERR("cellGameContentPermit() Error: 0x%x\n", ret);
}
else
{
SSNES_LOG("cellGameContentPermit() OK.\n");
SSNES_LOG("contentInfoPath : [%s].\n", contentInfoPath);
SSNES_LOG("usrDirPath : [%s].\n", usrDirPath);
}
/* now we fill in all the variables */
snprintf(SYS_CONFIG_FILE, sizeof(SYS_CONFIG_FILE), "%s/ssnes.cfg", usrDirPath);
snprintf(LIBSNES_DIR_PATH, sizeof(LIBSNES_DIR_PATH), "%s/cores", usrDirPath);
}
/* now we fill in all the variables */
snprintf(SYS_CONFIG_FILE, sizeof(SYS_CONFIG_FILE), "%s/ssnes.cfg", usrDirPath);
snprintf(LIBSNES_DIR_PATH, sizeof(LIBSNES_DIR_PATH), "%s/cores", usrDirPath);
}
}
int main(int argc, char *argv[])
{
CellPadData pad_data;
char spawn_data[256], spawn_data_size[16];
SceNpDrmKey * k_licensee = NULL;
int ret;
CellPadData pad_data;
char spawn_data[256], spawn_data_size[16];
SceNpDrmKey * k_licensee = NULL;
int ret;
cellSysmoduleLoadModule(CELL_SYSMODULE_IO);
cellSysmoduleLoadModule(CELL_SYSMODULE_FS);
cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_GAME);
cellSysmoduleLoadModule(CELL_SYSMODULE_NET);
cellSysmoduleLoadModule(CELL_SYSMODULE_IO);
cellSysmoduleLoadModule(CELL_SYSMODULE_FS);
cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_GAME);
cellSysmoduleLoadModule(CELL_SYSMODULE_NET);
cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_NP);
cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_NP);
sys_net_initialize_network();
sys_net_initialize_network();
#ifdef HAVE_LOGGER
logger_init();
logger_init();
#endif
sceNpInit(NP_POOL_SIZE, np_pool);
sceNpInit(NP_POOL_SIZE, np_pool);
get_environment_settings();
cellPadInit(7);
get_environment_settings();
cellPadGetData(0, &pad_data);
cellPadInit(7);
if(pad_data.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_TRIANGLE)
{
//override path, boot first SELF in cores directory
SSNES_LOG("Fallback - Will boot first SELF in SSNES cores/ directory.\n");
find_and_set_first_file();
}
else
{
//normal SELF loading path
init_settings();
}
cellPadGetData(0, &pad_data);
cellPadEnd();
if(pad_data.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_TRIANGLE)
{
//override path, boot first SELF in cores directory
SSNES_LOG("Fallback - Will boot first SELF in SSNES cores/ directory.\n");
find_and_set_first_file();
}
else
{
//normal SELF loading path
init_settings();
}
cellPadEnd();
#ifdef HAVE_LOGGER
logger_shutdown();
logger_shutdown();
#endif
for(unsigned int i = 0; i < sizeof(spawn_data); ++i)
spawn_data[i] = i & 0xff;
for(unsigned int i = 0; i < sizeof(spawn_data); ++i)
spawn_data[i] = i & 0xff;
sprintf(spawn_data_size, "%d", 256);
sprintf(spawn_data_size, "%d", 256);
const char * const spawn_argv[] = {
spawn_data_size,
"test argv for",
"sceNpDrmProcessExitSpawn2()",
NULL
};
const char * const spawn_argv[] = {
spawn_data_size,
"test argv for",
"sceNpDrmProcessExitSpawn2()",
NULL
};
ret = sceNpDrmProcessExitSpawn2(k_licensee, libretro_path, (const char** const)spawn_argv, NULL, (sys_addr_t)spawn_data, 256, 1000, SYS_PROCESS_PRIMARY_STACK_SIZE_1M);
SSNES_LOG("Launch libretro core: [%s] (return code: %x]).\n", libretro_path, ret);
if(ret < 0)
{
SSNES_LOG("SELF file is not of NPDRM type, trying another approach to boot it...\n");
sys_game_process_exitspawn2(libretro_path, NULL, NULL, NULL, 0, 1000, SYS_PROCESS_PRIMARY_STACK_SIZE_1M);
ret = sceNpDrmProcessExitSpawn2(k_licensee, libretro_path, (const char** const)spawn_argv, NULL, (sys_addr_t)spawn_data, 256, 1000, SYS_PROCESS_PRIMARY_STACK_SIZE_1M);
SSNES_LOG("Launch libretro core: [%s] (return code: %x]).\n", libretro_path, ret);
}
sceNpTerm();
if(ret < 0)
{
SSNES_LOG("SELF file is not of NPDRM type, trying another approach to boot it...\n");
sys_game_process_exitspawn2(libretro_path, NULL, NULL, NULL, 0, 1000, SYS_PROCESS_PRIMARY_STACK_SIZE_1M);
}
sys_net_finalize_network();
sceNpTerm();
cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_NP);
sys_net_finalize_network();
cellSysmoduleUnloadModule(CELL_SYSMODULE_NET);
cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_GAME);
cellSysmoduleLoadModule(CELL_SYSMODULE_FS);
cellSysmoduleLoadModule(CELL_SYSMODULE_IO);
cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_NP);
return 1;
cellSysmoduleUnloadModule(CELL_SYSMODULE_NET);
cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_GAME);
cellSysmoduleLoadModule(CELL_SYSMODULE_FS);
cellSysmoduleLoadModule(CELL_SYSMODULE_IO);
return 1;
}