From 84f7a2f5f878de3fa05935655d310c18aa50b802 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 9 Jan 2013 07:27:05 +0100 Subject: [PATCH] Indenting nits --- 360/frontend-xdk/menu.cpp | 20 +- 360/frontend-xdk/menu.h | 20 +- 360/xdk360_audio.cpp | 2 +- console/rarch_console_rom_ext.c | 4 +- frontend/platform/platform_xdk.c | 1 - xbox1/image.c | 40 ++-- xdk/menu_shared.h | 24 --- xdk/xdk_d3d.cpp | 24 +-- xdk/xdk_resources.cpp | 338 +++++++++++++++---------------- xdk/xdk_resources.h | 152 +++++++------- xdk/xdk_xinput_input.c | 18 +- 11 files changed, 309 insertions(+), 334 deletions(-) delete mode 100644 xdk/menu_shared.h diff --git a/360/frontend-xdk/menu.cpp b/360/frontend-xdk/menu.cpp index 73cb76ab6b..96a910ce9c 100644 --- a/360/frontend-xdk/menu.cpp +++ b/360/frontend-xdk/menu.cpp @@ -517,10 +517,10 @@ HRESULT CRetroArchSettings::OnControlNavigate(XUIMessageControlNavigate *pContro g_extern.console.rmenu.state.msg_info.enable = !g_extern.console.rmenu.state.msg_info.enable; m_settingslist.SetText(SETTING_EMU_SHOW_INFO_MSG, g_extern.console.rmenu.state.msg_info.enable ? L"Info messages: ON" : L"Info messages: OFF"); break; - case SETTING_EMU_SHOW_DEBUG_INFO_MSG: - g_extern.console.rmenu.state.msg_fps.enable = !g_extern.console.rmenu.state.msg_fps.enable; - m_settingslist.SetText(SETTING_EMU_SHOW_DEBUG_INFO_MSG, g_extern.console.rmenu.state.msg_fps.enable ? L"Debug Info messages: ON" : L"Debug Info messages: OFF"); - break; + case SETTING_EMU_SHOW_DEBUG_INFO_MSG: + g_extern.console.rmenu.state.msg_fps.enable = !g_extern.console.rmenu.state.msg_fps.enable; + m_settingslist.SetText(SETTING_EMU_SHOW_DEBUG_INFO_MSG, g_extern.console.rmenu.state.msg_fps.enable ? L"Debug Info messages: ON" : L"Debug Info messages: OFF"); + break; case SETTING_EMU_MENUS: g_extern.console.rmenu.state.rmenu_hd.enable = !g_extern.console.rmenu.state.rmenu_hd.enable; m_settingslist.SetText(SETTING_EMU_MENUS, g_extern.console.rmenu.state.rmenu_hd.enable ? L"Menus: HD" : L"Menus: SD"); @@ -576,10 +576,10 @@ HRESULT CRetroArchSettings::OnControlNavigate(XUIMessageControlNavigate *pContro g_extern.console.rmenu.state.msg_info.enable = !g_extern.console.rmenu.state.msg_info.enable; m_settingslist.SetText(SETTING_EMU_SHOW_INFO_MSG, g_extern.console.rmenu.state.msg_info.enable ? L"Info messages: ON" : L"Info messages: OFF"); break; - case SETTING_EMU_SHOW_DEBUG_INFO_MSG: - g_extern.console.rmenu.state.msg_fps.enable = !g_extern.console.rmenu.state.msg_fps.enable; - m_settingslist.SetText(SETTING_EMU_SHOW_DEBUG_INFO_MSG, g_extern.console.rmenu.state.msg_fps.enable ? L"Debug Info messages: ON" : L"Debug Info messages: OFF"); - break; + case SETTING_EMU_SHOW_DEBUG_INFO_MSG: + g_extern.console.rmenu.state.msg_fps.enable = !g_extern.console.rmenu.state.msg_fps.enable; + m_settingslist.SetText(SETTING_EMU_SHOW_DEBUG_INFO_MSG, g_extern.console.rmenu.state.msg_fps.enable ? L"Debug Info messages: ON" : L"Debug Info messages: OFF"); + break; case SETTING_EMU_MENUS: g_extern.console.rmenu.state.rmenu_hd.enable = !g_extern.console.rmenu.state.rmenu_hd.enable; m_settingslist.SetText(SETTING_EMU_MENUS, g_extern.console.rmenu.state.rmenu_hd.enable ? L"Menus: HD" : L"Menus: SD"); @@ -624,7 +624,7 @@ HRESULT CRetroArchSettings::OnControlNavigate(XUIMessageControlNavigate *pContro m_settingslist.SetText(SETTING_HW_TEXTURE_FILTER_2, g_settings.video.second_pass_smooth ? L"Hardware filtering shader #2: Linear interpolation" : L"Hardware filtering shader #2: Point filtering"); break; case SETTING_SCALE_ENABLED: - g_settings.video.render_to_texture = !g_settings.video.render_to_texture; + g_settings.video.render_to_texture = !g_settings.video.render_to_texture; m_settingslist.SetText(SETTING_SCALE_ENABLED, g_settings.video.render_to_texture ? L"Custom Scaling/Dual Shaders: ON" : L"Custom Scaling/Dual Shaders: OFF"); if(g_settings.video.render_to_texture) @@ -1201,7 +1201,7 @@ bool rmenu_iterate(void) } } - rarch_render_cached_frame(); + rarch_render_cached_frame(); switch(g_extern.console.rmenu.input_loop) { diff --git a/360/frontend-xdk/menu.h b/360/frontend-xdk/menu.h index 327d447627..dafeb6404e 100644 --- a/360/frontend-xdk/menu.h +++ b/360/frontend-xdk/menu.h @@ -92,7 +92,7 @@ class CRetroArchMain: public CXuiSceneImpl CXuiControl m_quit; CXuiTextElement m_title; CXuiTextElement m_core; - CXuiControl m_logoimage; + CXuiControl m_logoimage; public: HRESULT OnInit( XUIMessageInit* pInitData, int & bHandled ); HRESULT OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled ); @@ -100,7 +100,7 @@ class CRetroArchMain: public CXuiSceneImpl XUI_BEGIN_MSG_MAP() XUI_ON_XM_INIT( OnInit) XUI_ON_XM_NOTIFY_PRESS( OnNotifyPress ) - XUI_END_MSG_MAP(); + XUI_END_MSG_MAP(); XUI_IMPLEMENT_CLASS(CRetroArchMain, L"RetroArchMain", XUI_CLASS_SCENE) }; @@ -120,7 +120,7 @@ class CRetroArchFileBrowser: public CXuiSceneImpl XUI_BEGIN_MSG_MAP() XUI_ON_XM_INIT( OnInit) XUI_ON_XM_NOTIFY_PRESS( OnNotifyPress ) - XUI_END_MSG_MAP(); + XUI_END_MSG_MAP(); XUI_IMPLEMENT_CLASS(CRetroArchFileBrowser, L"RetroArchFileBrowser", XUI_CLASS_SCENE) }; @@ -136,9 +136,9 @@ class CRetroArchCoreBrowser: public CXuiSceneImpl HRESULT OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled ); XUI_BEGIN_MSG_MAP() - XUI_ON_XM_INIT( OnInit) - XUI_ON_XM_NOTIFY_PRESS( OnNotifyPress ) - XUI_END_MSG_MAP(); + XUI_ON_XM_INIT( OnInit) + XUI_ON_XM_NOTIFY_PRESS( OnNotifyPress ) + XUI_END_MSG_MAP(); XUI_IMPLEMENT_CLASS(CRetroArchCoreBrowser, L"RetroArchCoreBrowser", XUI_CLASS_SCENE) }; @@ -156,7 +156,7 @@ class CRetroArchShaderBrowser: public CXuiSceneImpl XUI_BEGIN_MSG_MAP() XUI_ON_XM_INIT( OnInit) XUI_ON_XM_NOTIFY_PRESS( OnNotifyPress ) - XUI_END_MSG_MAP(); + XUI_END_MSG_MAP(); XUI_IMPLEMENT_CLASS(CRetroArchShaderBrowser, L"RetroArchShaderBrowser", XUI_CLASS_SCENE) }; @@ -175,7 +175,7 @@ class CRetroArchQuickMenu: public CXuiSceneImpl XUI_ON_XM_INIT( OnInit) XUI_ON_XM_CONTROL_NAVIGATE( OnControlNavigate ) XUI_ON_XM_NOTIFY_PRESS( OnNotifyPress ) - XUI_END_MSG_MAP(); + XUI_END_MSG_MAP(); XUI_IMPLEMENT_CLASS(CRetroArchQuickMenu, L"RetroArchQuickMenu", XUI_CLASS_SCENE) }; @@ -194,7 +194,7 @@ class CRetroArchSettings: public CXuiSceneImpl XUI_ON_XM_INIT( OnInit) XUI_ON_XM_CONTROL_NAVIGATE( OnControlNavigate ) XUI_ON_XM_NOTIFY_PRESS( OnNotifyPress ) - XUI_END_MSG_MAP(); + XUI_END_MSG_MAP(); XUI_IMPLEMENT_CLASS(CRetroArchSettings, L"RetroArchSettings", XUI_CLASS_SCENE) }; @@ -214,7 +214,7 @@ class CRetroArchControls: public CXuiSceneImpl XUI_ON_XM_INIT( OnInit) XUI_ON_XM_CONTROL_NAVIGATE( OnControlNavigate ) XUI_ON_XM_NOTIFY_PRESS( OnNotifyPress ) - XUI_END_MSG_MAP(); + XUI_END_MSG_MAP(); XUI_IMPLEMENT_CLASS(CRetroArchControls, L"RetroArchControls", XUI_CLASS_SCENE) }; diff --git a/360/xdk360_audio.cpp b/360/xdk360_audio.cpp index 9332eb109d..cb13057698 100644 --- a/360/xdk360_audio.cpp +++ b/360/xdk360_audio.cpp @@ -164,7 +164,7 @@ static void *xa_init(const char *device, unsigned rate, unsigned latency) XAudio *xa = new XAudio; if (!xa->init(rate, latency)) - goto error; + goto error; return xa; diff --git a/console/rarch_console_rom_ext.c b/console/rarch_console_rom_ext.c index f2b952f03b..6423d32a5b 100644 --- a/console/rarch_console_rom_ext.c +++ b/console/rarch_console_rom_ext.c @@ -220,7 +220,7 @@ void rarch_console_load_game_wrap(const char *path, unsigned extract_zip_mode, u #ifdef HAVE_ZLIB extract_zip_cond = (strstr(path, ".zip") || strstr(path, ".ZIP")) - && !info.block_extract; + && !info.block_extract; if(extract_zip_cond) { @@ -230,7 +230,7 @@ void rarch_console_load_game_wrap(const char *path, unsigned extract_zip_mode, u } extract_zip_and_load_game_cond = (extract_zip_cond && - g_extern.file_state.zip_extract_mode == ZIP_EXTRACT_TO_CURRENT_DIR_AND_LOAD_FIRST_FILE); + g_extern.file_state.zip_extract_mode == ZIP_EXTRACT_TO_CURRENT_DIR_AND_LOAD_FIRST_FILE); load_game = (extract_zip_and_load_game_cond) || (!extract_zip_cond); if(extract_zip_and_load_game_cond) diff --git a/frontend/platform/platform_xdk.c b/frontend/platform/platform_xdk.c index ad2b5233b6..d523cf59e4 100644 --- a/frontend/platform/platform_xdk.c +++ b/frontend/platform/platform_xdk.c @@ -26,7 +26,6 @@ #if defined(_XBOX360) #include #include "../../360/frontend-xdk/menu.h" -#include "../../xdk/menu_shared.h" #elif defined(_XBOX1) #include "../../console/rmenu/rmenu.h" #endif diff --git a/xbox1/image.c b/xbox1/image.c index c2acf8168a..cfa767113e 100644 --- a/xbox1/image.c +++ b/xbox1/image.c @@ -1,18 +1,18 @@ /* RetroArch - A frontend for libretro. -* Copyright (C) 2010-2013 - Hans-Kristian Arntzen -* Copyright (C) 2011-2013 - Daniel De Matteis -* -* RetroArch is free software: you can redistribute it and/or modify it under the terms -* of the GNU General Public License as published by the Free Software Found- -* ation, either version 3 of the License, or (at your option) any later version. -* -* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; -* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -* PURPOSE. See the GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License along with RetroArch. -* If not, see . -*/ + * Copyright (C) 2010-2013 - Hans-Kristian Arntzen + * Copyright (C) 2011-2013 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ #include "../gfx/image.h" #include "../xdk/xdk_d3d.h" @@ -20,16 +20,16 @@ bool texture_image_load(const char *path, struct texture_image *out_img) { xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data; - + D3DXIMAGE_INFO m_imageInfo; out_img->pixels = NULL; out_img->vertex_buf = NULL; HRESULT ret = D3DXCreateTextureFromFileExA(d3d->d3d_render_device, - path, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_A8R8G8B8, - D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, &m_imageInfo, NULL, - &out_img->pixels); + path, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_A8R8G8B8, + D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, &m_imageInfo, NULL, + &out_img->pixels); if(FAILED(ret)) { @@ -39,7 +39,7 @@ bool texture_image_load(const char *path, struct texture_image *out_img) // create a vertex buffer for the quad that will display the texture ret = d3d->d3d_render_device->CreateVertexBuffer(4 * sizeof(DrawVerticeFormats), - D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED, &out_img->vertex_buf); + D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED, &out_img->vertex_buf); if (FAILED(ret)) { @@ -47,7 +47,7 @@ bool texture_image_load(const char *path, struct texture_image *out_img) out_img->pixels->Release(); return false; } - + out_img->width = m_imageInfo.Width; out_img->height = m_imageInfo.Height; diff --git a/xdk/menu_shared.h b/xdk/menu_shared.h deleted file mode 100644 index fc14b892e1..0000000000 --- a/xdk/menu_shared.h +++ /dev/null @@ -1,24 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2013 - Hans-Kristian Arntzen - * Copyright (C) 2011-2013 - Daniel De Matteis - * - * RetroArch is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . - */ - -#ifndef _XDK_MENU_SHARED_H -#define _XDK_MENU_SHARED_H - -void menu_init (void); -void menu_free (void); -bool rmenu_iterate(void); - -#endif diff --git a/xdk/xdk_d3d.cpp b/xdk/xdk_d3d.cpp index 59db25ebc8..968c0b5d01 100644 --- a/xdk/xdk_d3d.cpp +++ b/xdk/xdk_d3d.cpp @@ -796,16 +796,16 @@ static bool xdk_d3d_frame(void *data, const void *frame, if(frame) { - D3DLOCKED_RECT d3dlr; - d3d->lpTexture->LockRect(0, &d3dlr, NULL, D3DLOCK_NOSYSLOCK); + D3DLOCKED_RECT d3dlr; + d3d->lpTexture->LockRect(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 * d3d->base_size); - } - d3d->lpTexture->UnlockRect(0); + 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 * d3d->base_size); + } + d3d->lpTexture->UnlockRect(0); } d3d->d3d_render_device->SetSamplerState(0, D3DSAMP_MINFILTER, g_settings.video.smooth ? D3DTEXF_LINEAR : D3DTEXF_POINT); @@ -885,7 +885,7 @@ static bool xdk_d3d_frame(void *data, const void *frame, snprintf(buf, sizeof(buf), "%.2f MB free / %.2f MB total", stat.dwAvailPhys/(1024.0f*1024.0f), stat.dwTotalPhys/(1024.0f*1024.0f)); if (d3d->font_ctx) - d3d->font_ctx->render_msg_place(d3d, mem_width, mem_height, 0, 0, buf); + d3d->font_ctx->render_msg_place(d3d, mem_width, mem_height, 0, 0, buf); gfx_get_fps(fps_txt, sizeof(fps_txt), true); if (d3d->font_ctx) @@ -901,8 +901,8 @@ static bool xdk_d3d_frame(void *data, const void *frame, app.Render(); XuiTimersRun(); #endif - } - else + } + else gfx_ctx_xdk_swap_buffers(); return true; diff --git a/xdk/xdk_resources.cpp b/xdk/xdk_resources.cpp index b8b5b2359b..d42b0a8c7a 100644 --- a/xdk/xdk_resources.cpp +++ b/xdk/xdk_resources.cpp @@ -20,9 +20,9 @@ #ifdef _XBOX360 struct XPR_HEADER { - DWORD dwMagic; - DWORD dwHeaderSize; - DWORD dwDataSize; + DWORD dwMagic; + DWORD dwHeaderSize; + DWORD dwDataSize; }; #endif @@ -34,60 +34,60 @@ const DWORD eXALLOCAllocatorId_AtgResource = eXALLOCAllocatorId_GameMax; PackedResource::PackedResource() { - m_pSysMemData = NULL; - m_dwSysMemDataSize = 0L; - m_pVidMemData = NULL; - m_dwVidMemDataSize = 0L; - m_pResourceTags = NULL; - m_dwNumResourceTags = 0L; - m_bInitialized = FALSE; + m_pSysMemData = NULL; + m_dwSysMemDataSize = 0L; + m_pVidMemData = NULL; + m_dwVidMemDataSize = 0L; + m_pResourceTags = NULL; + m_dwNumResourceTags = 0L; + m_bInitialized = FALSE; } PackedResource::~PackedResource() { - Destroy(); + Destroy(); } void *PackedResource::GetData( const CHAR* strName ) const { - if( NULL == m_pResourceTags || NULL == strName ) - return NULL; + if( NULL == m_pResourceTags || NULL == strName ) + return NULL; #if defined(_XBOX1) - for( DWORD i=0; m_pResourceTags[i].strName; i++ ) + for( DWORD i=0; m_pResourceTags[i].strName; i++ ) #elif defined(_XBOX360) - for( DWORD i = 0; i < m_dwNumResourceTags; i++ ) + for( DWORD i = 0; i < m_dwNumResourceTags; i++ ) #endif - { - if( !_stricmp( strName, m_pResourceTags[i].strName ) ) - { + { + if( !_stricmp( strName, m_pResourceTags[i].strName ) ) + { return &m_pSysMemData[m_pResourceTags[i].dwOffset]; - } - } + } + } - return NULL; + return NULL; } static __forceinline void* AllocateContiguousMemory( DWORD Size, DWORD Alignment, - DWORD Protection = XALLOC_MEMPROTECT_WRITECOMBINE ) + DWORD Protection = XALLOC_MEMPROTECT_WRITECOMBINE ) { #if defined(_XBOX1) - return D3D_AllocContiguousMemory(Size, Alignment); + return D3D_AllocContiguousMemory(Size, Alignment); #elif defined(_XBOX360) - return XMemAlloc( Size, MAKE_XALLOC_ATTRIBUTES( 0, 0, 0, 0, eXALLOCAllocatorId_AtgResource, - Alignment, Protection, 0, - XALLOC_MEMTYPE_PHYSICAL ) ); + return XMemAlloc( Size, MAKE_XALLOC_ATTRIBUTES( 0, 0, 0, 0, eXALLOCAllocatorId_AtgResource, + Alignment, Protection, 0, + XALLOC_MEMTYPE_PHYSICAL ) ); #endif } static __forceinline void FreeContiguousMemory( void* pData ) { #if defined(_XBOX1) - return D3D_FreeContiguousMemory(pData); + return D3D_FreeContiguousMemory(pData); #elif defined(_XBOX360) - return XMemFree( pData, MAKE_XALLOC_ATTRIBUTES( 0, 0, 0, 0, eXALLOCAllocatorId_AtgResource, - 0, 0, 0, XALLOC_MEMTYPE_PHYSICAL ) ); + return XMemFree( pData, MAKE_XALLOC_ATTRIBUTES( 0, 0, 0, 0, eXALLOCAllocatorId_AtgResource, + 0, 0, 0, XALLOC_MEMTYPE_PHYSICAL ) ); #endif } @@ -96,219 +96,219 @@ char g_strMediaPath[512] = "D:\\Media\\"; static HRESULT FindMediaFile( char *strPath, const char *strFilename, size_t strPathsize) { - // Check for valid arguments - if( strFilename == NULL || strPath == NULL ) - { - RARCH_ERR("Util_FindMediaFile(): Invalid arguments\n" ); - return E_INVALIDARG; - } + // Check for valid arguments + if( strFilename == NULL || strPath == NULL ) + { + RARCH_ERR("Util_FindMediaFile(): Invalid arguments\n" ); + return E_INVALIDARG; + } - // Default path is the filename itself as a fully qualified path - strlcpy( strPath, strFilename, strPathsize); + // Default path is the filename itself as a fully qualified path + strlcpy( strPath, strFilename, strPathsize); - // Check for the ':' character to see if the filename is a fully - // qualified path. If not, pre-pend the media directory - if(strFilename[1] != ':') - snprintf(strPath, strPathsize, "%s%s", g_strMediaPath, strFilename); + // Check for the ':' character to see if the filename is a fully + // qualified path. If not, pre-pend the media directory + if(strFilename[1] != ':') + snprintf(strPath, strPathsize, "%s%s", g_strMediaPath, strFilename); - // Try to open the file - HANDLE hFile = CreateFile( strPath, GENERIC_READ, FILE_SHARE_READ, NULL, - OPEN_EXISTING, 0, NULL ); + // Try to open the file + HANDLE hFile = CreateFile( strPath, GENERIC_READ, FILE_SHARE_READ, NULL, + OPEN_EXISTING, 0, NULL ); - if( hFile == INVALID_HANDLE_VALUE ) - { - RARCH_ERR("FindMediaFile(): Could not find file.\n"); - return 0x82000004; - } + if( hFile == INVALID_HANDLE_VALUE ) + { + RARCH_ERR("FindMediaFile(): Could not find file.\n"); + return 0x82000004; + } - // Found the file. Close the file and return - CloseHandle( hFile ); + // Found the file. Close the file and return + CloseHandle( hFile ); - return S_OK; + return S_OK; } #endif #if defined(_XBOX1) HRESULT PackedResource::Create( const char *strFilename, -DWORD dwNumResourceTags, XBRESOURCE* pResourceTags) + DWORD dwNumResourceTags, XBRESOURCE* pResourceTags) #elif defined(_XBOX360) HRESULT PackedResource::Create( const char *strFilename ) #endif { #ifdef _XBOX1 - BOOL bHasResourceOffsetsTable = FALSE; + BOOL bHasResourceOffsetsTable = FALSE; - // Find the media file - CHAR strResourcePath[512]; - if( FAILED(FindMediaFile(strResourcePath, strFilename, sizeof(strResourcePath)))) - return E_FAIL; - else - strFilename = strResourcePath; + // Find the media file + CHAR strResourcePath[512]; + if( FAILED(FindMediaFile(strResourcePath, strFilename, sizeof(strResourcePath)))) + return E_FAIL; + else + strFilename = strResourcePath; #endif - // Open the file - HANDLE hFile; - DWORD dwNumBytesRead; - hFile = CreateFile( strFilename, GENERIC_READ, FILE_SHARE_READ, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL ); - if( hFile == INVALID_HANDLE_VALUE ) - { - RARCH_ERR( "PackedResource::Create(): File <%s> not found.\n", strFilename ); - return E_FAIL; - } + // Open the file + HANDLE hFile; + DWORD dwNumBytesRead; + hFile = CreateFile( strFilename, GENERIC_READ, FILE_SHARE_READ, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL ); + if( hFile == INVALID_HANDLE_VALUE ) + { + RARCH_ERR( "PackedResource::Create(): File <%s> not found.\n", strFilename ); + return E_FAIL; + } - // Read in and verify the XPR magic header - XPR_HEADER xprh; - bool retval = ReadFile( hFile, &xprh, sizeof( XPR_HEADER ), &dwNumBytesRead, NULL ); + // Read in and verify the XPR magic header + XPR_HEADER xprh; + bool retval = ReadFile( hFile, &xprh, sizeof( XPR_HEADER ), &dwNumBytesRead, NULL ); #if defined(_XBOX1) - if( xprh.dwMagic == XPR0_MAGIC_VALUE ) - { - bHasResourceOffsetsTable = FALSE; - } - else if( xprh.dwMagic == XPR1_MAGIC_VALUE ) - { - bHasResourceOffsetsTable = TRUE; - } - else + if( xprh.dwMagic == XPR0_MAGIC_VALUE ) + { + bHasResourceOffsetsTable = FALSE; + } + else if( xprh.dwMagic == XPR1_MAGIC_VALUE ) + { + bHasResourceOffsetsTable = TRUE; + } + else #elif defined(_XBOX360) - if(!retval) - { - RARCH_ERR("Error reading XPR header in file %s.\n", strFilename ); - CloseHandle( hFile ); - return E_FAIL; - } + if(!retval) + { + RARCH_ERR("Error reading XPR header in file %s.\n", strFilename ); + CloseHandle( hFile ); + return E_FAIL; + } - if( xprh.dwMagic != XPR2_MAGIC_VALUE ) + if( xprh.dwMagic != XPR2_MAGIC_VALUE ) #endif - { - RARCH_ERR( "Invalid Xbox Packed Resource (.xpr) file: Magic = 0x%08lx\n", xprh.dwMagic ); - CloseHandle( hFile ); - return E_FAIL; - } + { + RARCH_ERR( "Invalid Xbox Packed Resource (.xpr) file: Magic = 0x%08lx\n", xprh.dwMagic ); + CloseHandle( hFile ); + return E_FAIL; + } - // Compute memory requirements + // Compute memory requirements #if defined(_XBOX1) - m_dwSysMemDataSize = xprh.dwHeaderSize - sizeof(XPR_HEADER); - m_dwVidMemDataSize = xprh.dwTotalSize - xprh.dwHeaderSize; + m_dwSysMemDataSize = xprh.dwHeaderSize - sizeof(XPR_HEADER); + m_dwVidMemDataSize = xprh.dwTotalSize - xprh.dwHeaderSize; #elif defined(_XBOX360) - m_dwSysMemDataSize = xprh.dwHeaderSize; - m_dwVidMemDataSize = xprh.dwDataSize; + m_dwSysMemDataSize = xprh.dwHeaderSize; + m_dwVidMemDataSize = xprh.dwDataSize; #endif - // Allocate memory - m_pSysMemData = (BYTE*)malloc(m_dwSysMemDataSize); - if( m_pSysMemData == NULL ) - { - RARCH_ERR( "Could not allocate system memory.\n" ); - m_dwSysMemDataSize = 0; - return E_FAIL; - } + // Allocate memory + m_pSysMemData = (BYTE*)malloc(m_dwSysMemDataSize); + if( m_pSysMemData == NULL ) + { + RARCH_ERR( "Could not allocate system memory.\n" ); + m_dwSysMemDataSize = 0; + return E_FAIL; + } - m_pVidMemData = ( BYTE* )AllocateContiguousMemory( m_dwVidMemDataSize, + m_pVidMemData = ( BYTE* )AllocateContiguousMemory( m_dwVidMemDataSize, #if defined(_XBOX1) -D3DTEXTURE_ALIGNMENT + D3DTEXTURE_ALIGNMENT #elif defined(_XBOX360) -XALLOC_PHYSICAL_ALIGNMENT_4K + XALLOC_PHYSICAL_ALIGNMENT_4K #endif - ); + ); - if( m_pVidMemData == NULL ) - { - RARCH_ERR( "Could not allocate physical memory.\n" ); - m_dwSysMemDataSize = 0; - m_dwVidMemDataSize = 0; - free(m_pSysMemData); - m_pSysMemData = NULL; - return E_FAIL; - } + if( m_pVidMemData == NULL ) + { + RARCH_ERR( "Could not allocate physical memory.\n" ); + m_dwSysMemDataSize = 0; + m_dwVidMemDataSize = 0; + free(m_pSysMemData); + m_pSysMemData = NULL; + return E_FAIL; + } - // Read in the data from the file - if( !ReadFile( hFile, m_pSysMemData, m_dwSysMemDataSize, &dwNumBytesRead, NULL ) || - !ReadFile( hFile, m_pVidMemData, m_dwVidMemDataSize, &dwNumBytesRead, NULL ) ) - { - RARCH_ERR( "Unable to read Xbox Packed Resource (.xpr) file\n" ); - CloseHandle( hFile ); - return E_FAIL; - } + // Read in the data from the file + if( !ReadFile( hFile, m_pSysMemData, m_dwSysMemDataSize, &dwNumBytesRead, NULL ) || + !ReadFile( hFile, m_pVidMemData, m_dwVidMemDataSize, &dwNumBytesRead, NULL ) ) + { + RARCH_ERR( "Unable to read Xbox Packed Resource (.xpr) file\n" ); + CloseHandle( hFile ); + return E_FAIL; + } - // Done with the file - CloseHandle( hFile ); + // Done with the file + CloseHandle( hFile ); #ifdef _XBOX1 - if (bHasResourceOffsetsTable) - { + if (bHasResourceOffsetsTable) + { #endif - // Extract resource table from the header data - m_dwNumResourceTags = *( DWORD* )( m_pSysMemData + 0 ); - m_pResourceTags = ( XBRESOURCE* )( m_pSysMemData + 4 ); + // Extract resource table from the header data + m_dwNumResourceTags = *( DWORD* )( m_pSysMemData + 0 ); + m_pResourceTags = ( XBRESOURCE* )( m_pSysMemData + 4 ); - // Patch up the resources - for( DWORD i = 0; i < m_dwNumResourceTags; i++ ) - { - m_pResourceTags[i].strName = ( CHAR* )( m_pSysMemData + ( DWORD )m_pResourceTags[i].strName ); + // Patch up the resources + for( DWORD i = 0; i < m_dwNumResourceTags; i++ ) + { + m_pResourceTags[i].strName = ( CHAR* )( m_pSysMemData + ( DWORD )m_pResourceTags[i].strName ); #ifdef _XBOX360 - // Fixup the texture memory - if( ( m_pResourceTags[i].dwType & 0xffff0000 ) == ( RESOURCETYPE_TEXTURE & 0xffff0000 ) ) - { + // Fixup the texture memory + if( ( m_pResourceTags[i].dwType & 0xffff0000 ) == ( RESOURCETYPE_TEXTURE & 0xffff0000 ) ) + { D3DTexture* pTexture = ( D3DTexture* )&m_pSysMemData[m_pResourceTags[i].dwOffset]; // Adjust Base address according to where memory was allocated XGOffsetBaseTextureAddress( pTexture, m_pVidMemData, m_pVidMemData ); - } + } #endif - } + } #ifdef _XBOX1 - } + } #endif #ifdef _XBOX1 - // Use user-supplied number of resources and the resource tags - if( dwNumResourceTags != 0 || pResourceTags != NULL ) - { - m_pResourceTags = pResourceTags; - m_dwNumResourceTags = dwNumResourceTags; - } + // Use user-supplied number of resources and the resource tags + if( dwNumResourceTags != 0 || pResourceTags != NULL ) + { + m_pResourceTags = pResourceTags; + m_dwNumResourceTags = dwNumResourceTags; + } #endif - m_bInitialized = TRUE; + m_bInitialized = TRUE; - return S_OK; + return S_OK; } #ifdef _XBOX360 void PackedResource::GetResourceTags( DWORD* pdwNumResourceTags, - XBRESOURCE** ppResourceTags ) + XBRESOURCE** ppResourceTags ) { - if( pdwNumResourceTags ) - ( *pdwNumResourceTags ) = m_dwNumResourceTags; + if( pdwNumResourceTags ) + ( *pdwNumResourceTags ) = m_dwNumResourceTags; - if( ppResourceTags ) - ( *ppResourceTags ) = m_pResourceTags; + if( ppResourceTags ) + ( *ppResourceTags ) = m_pResourceTags; } #endif void PackedResource::Destroy() { - free(m_pSysMemData); - m_pSysMemData = NULL; - m_dwSysMemDataSize = 0L; + free(m_pSysMemData); + m_pSysMemData = NULL; + m_dwSysMemDataSize = 0L; - if( m_pVidMemData != NULL ) - FreeContiguousMemory( m_pVidMemData ); - m_pVidMemData = NULL; - m_dwVidMemDataSize = 0L; + if( m_pVidMemData != NULL ) + FreeContiguousMemory( m_pVidMemData ); + m_pVidMemData = NULL; + m_dwVidMemDataSize = 0L; - m_pResourceTags = NULL; - m_dwNumResourceTags = 0L; + m_pResourceTags = NULL; + m_dwNumResourceTags = 0L; - m_bInitialized = FALSE; + m_bInitialized = FALSE; } BOOL PackedResource::Initialized() const { - return m_bInitialized; + return m_bInitialized; } diff --git a/xdk/xdk_resources.h b/xdk/xdk_resources.h index 72f6f0a95b..aa16867977 100644 --- a/xdk/xdk_resources.h +++ b/xdk/xdk_resources.h @@ -25,130 +25,130 @@ DWORD XBResource_SizeOf( LPDIRECT3DRESOURCE pResource ); struct XBRESOURCE { #if defined(_XBOX1) - CHAR* strName; - DWORD dwOffset; + CHAR* strName; + DWORD dwOffset; #elif defined(_XBOX360) - DWORD dwType; - DWORD dwOffset; - DWORD dwSize; - CHAR* strName; + DWORD dwType; + DWORD dwOffset; + DWORD dwSize; + CHAR* strName; #endif }; // Resource types enum { - RESOURCETYPE_USERDATA = ( ( 'U' << 24 ) | ( 'S' << 16 ) | ( 'E' << 8 ) | ( 'R' ) ), - RESOURCETYPE_TEXTURE = ( ( 'T' << 24 ) | ( 'X' << 16 ) | ( '2' << 8 ) | ( 'D' ) ), - RESOURCETYPE_CUBEMAP = ( ( 'T' << 24 ) | ( 'X' << 16 ) | ( 'C' << 8 ) | ( 'M' ) ), - RESOURCETYPE_VOLUMETEXTURE = ( ( 'T' << 24 ) | ( 'X' << 16 ) | ( '3' << 8 ) | ( 'D' ) ), - RESOURCETYPE_VERTEXBUFFER = ( ( 'V' << 24 ) | ( 'B' << 16 ) | ( 'U' << 8 ) | ( 'F' ) ), - RESOURCETYPE_INDEXBUFFER = ( ( 'I' << 24 ) | ( 'B' << 16 ) | ( 'U' << 8 ) | ( 'F' ) ), - RESOURCETYPE_EOF = 0xffffffff + RESOURCETYPE_USERDATA = ( ( 'U' << 24 ) | ( 'S' << 16 ) | ( 'E' << 8 ) | ( 'R' ) ), + RESOURCETYPE_TEXTURE = ( ( 'T' << 24 ) | ( 'X' << 16 ) | ( '2' << 8 ) | ( 'D' ) ), + RESOURCETYPE_CUBEMAP = ( ( 'T' << 24 ) | ( 'X' << 16 ) | ( 'C' << 8 ) | ( 'M' ) ), + RESOURCETYPE_VOLUMETEXTURE = ( ( 'T' << 24 ) | ( 'X' << 16 ) | ( '3' << 8 ) | ( 'D' ) ), + RESOURCETYPE_VERTEXBUFFER = ( ( 'V' << 24 ) | ( 'B' << 16 ) | ( 'U' << 8 ) | ( 'F' ) ), + RESOURCETYPE_INDEXBUFFER = ( ( 'I' << 24 ) | ( 'B' << 16 ) | ( 'U' << 8 ) | ( 'F' ) ), + RESOURCETYPE_EOF = 0xffffffff }; class PackedResource { -protected: - BYTE* m_pSysMemData; // Alloc'ed memory for resource headers etc. - DWORD m_dwSysMemDataSize; + protected: + BYTE* m_pSysMemData; // Alloc'ed memory for resource headers etc. + DWORD m_dwSysMemDataSize; - BYTE* m_pVidMemData; // Alloc'ed memory for resource data, etc. - DWORD m_dwVidMemDataSize; - - XBRESOURCE* m_pResourceTags; // Tags to associate names with the resources - DWORD m_dwNumResourceTags; // Number of resource tags - BOOL m_bInitialized; // Resource is fully initialized + BYTE* m_pVidMemData; // Alloc'ed memory for resource data, etc. + DWORD m_dwVidMemDataSize; -public: - // Loads the resources out of the specified bundle + XBRESOURCE* m_pResourceTags; // Tags to associate names with the resources + DWORD m_dwNumResourceTags; // Number of resource tags + BOOL m_bInitialized; // Resource is fully initialized + + public: + // Loads the resources out of the specified bundle #if defined(_XBOX1) - HRESULT Create( const char *strFilename, DWORD dwNumResourceTags = 0L, - XBRESOURCE* pResourceTags = NULL ); + HRESULT Create( const char *strFilename, DWORD dwNumResourceTags = 0L, + XBRESOURCE* pResourceTags = NULL ); #elif defined(_XBOX360) - HRESULT Create( const char * strFilename ); + HRESULT Create( const char * strFilename ); #endif - void Destroy(); + void Destroy(); - BOOL Initialized() const; + BOOL Initialized() const; #ifdef _XBOX360 - // Retrieves the resource tags - void GetResourceTags( DWORD* pdwNumResourceTags, XBRESOURCE** ppResourceTags ); + // Retrieves the resource tags + void GetResourceTags( DWORD* pdwNumResourceTags, XBRESOURCE** ppResourceTags ); #endif - // Helper function to make sure a resource is registered - LPDIRECT3DRESOURCE RegisterResource( LPDIRECT3DRESOURCE pResource ) const - { + // Helper function to make sure a resource is registered + LPDIRECT3DRESOURCE RegisterResource( LPDIRECT3DRESOURCE pResource ) const + { #ifdef _XBOX1 - // Register the resource, if it has not yet been registered. We mark - // a resource as registered by upping it's reference count. - if( pResource && ( pResource->Common & D3DCOMMON_REFCOUNT_MASK ) == 1 ) - { + // Register the resource, if it has not yet been registered. We mark + // a resource as registered by upping it's reference count. + if( pResource && ( pResource->Common & D3DCOMMON_REFCOUNT_MASK ) == 1 ) + { // Special case CPU-copy push buffers (which live in system memory) if( ( pResource->Common & D3DCOMMON_TYPE_PUSHBUFFER ) && - ( pResource->Common & D3DPUSHBUFFER_RUN_USING_CPU_COPY ) ) - pResource->Data += (DWORD)m_pSysMemData; + ( pResource->Common & D3DPUSHBUFFER_RUN_USING_CPU_COPY ) ) + pResource->Data += (DWORD)m_pSysMemData; else - pResource->Register( m_pVidMemData ); + pResource->Register( m_pVidMemData ); pResource->AddRef(); - } + } #endif - return pResource; - } + return pResource; + } - // Functions to retrieve resources by their offset - void *GetData( DWORD dwOffset ) const - { return &m_pSysMemData[dwOffset]; } + // Functions to retrieve resources by their offset + void *GetData( DWORD dwOffset ) const + { return &m_pSysMemData[dwOffset]; } - LPDIRECT3DRESOURCE GetResource( DWORD dwOffset ) const - { return RegisterResource( (LPDIRECT3DRESOURCE)GetData(dwOffset) ); } + LPDIRECT3DRESOURCE GetResource( DWORD dwOffset ) const + { return RegisterResource( (LPDIRECT3DRESOURCE)GetData(dwOffset) ); } - LPDIRECT3DTEXTURE GetTexture( DWORD dwOffset ) const - { return (LPDIRECT3DTEXTURE)GetResource( dwOffset ); } + LPDIRECT3DTEXTURE GetTexture( DWORD dwOffset ) const + { return (LPDIRECT3DTEXTURE)GetResource( dwOffset ); } - LPDIRECT3DCUBETEXTURE GetCubemap( DWORD dwOffset ) const - { return (LPDIRECT3DCUBETEXTURE)GetResource( dwOffset ); } + LPDIRECT3DCUBETEXTURE GetCubemap( DWORD dwOffset ) const + { return (LPDIRECT3DCUBETEXTURE)GetResource( dwOffset ); } - LPDIRECT3DVOLUMETEXTURE GetVolumeTexture( DWORD dwOffset ) const - { return (LPDIRECT3DVOLUMETEXTURE)GetResource( dwOffset ); } + LPDIRECT3DVOLUMETEXTURE GetVolumeTexture( DWORD dwOffset ) const + { return (LPDIRECT3DVOLUMETEXTURE)GetResource( dwOffset ); } - LPDIRECT3DVERTEXBUFFER GetVertexBuffer( DWORD dwOffset ) const - { return (LPDIRECT3DVERTEXBUFFER)GetResource( dwOffset ); } + LPDIRECT3DVERTEXBUFFER GetVertexBuffer( DWORD dwOffset ) const + { return (LPDIRECT3DVERTEXBUFFER)GetResource( dwOffset ); } #ifdef _XBOX1 - LPDIRECT3DPUSHBUFFER8 GetPushBuffer( DWORD dwOffset ) const - { return (LPDIRECT3DPUSHBUFFER8)GetResource( dwOffset ); } + LPDIRECT3DPUSHBUFFER8 GetPushBuffer( DWORD dwOffset ) const + { return (LPDIRECT3DPUSHBUFFER8)GetResource( dwOffset ); } #endif - // Functions to retrieve resources by their name - void *GetData( const CHAR* strName ) const; + // Functions to retrieve resources by their name + void *GetData( const CHAR* strName ) const; - LPDIRECT3DRESOURCE GetResource( const CHAR* strName ) const - { return RegisterResource( (LPDIRECT3DRESOURCE)GetData( strName ) ); } + LPDIRECT3DRESOURCE GetResource( const CHAR* strName ) const + { return RegisterResource( (LPDIRECT3DRESOURCE)GetData( strName ) ); } - LPDIRECT3DTEXTURE GetTexture( const CHAR* strName ) const - { return (LPDIRECT3DTEXTURE)GetResource( strName ); } + LPDIRECT3DTEXTURE GetTexture( const CHAR* strName ) const + { return (LPDIRECT3DTEXTURE)GetResource( strName ); } - LPDIRECT3DCUBETEXTURE GetCubemap( const CHAR* strName ) const - { return (LPDIRECT3DCUBETEXTURE)GetResource( strName ); } + LPDIRECT3DCUBETEXTURE GetCubemap( const CHAR* strName ) const + { return (LPDIRECT3DCUBETEXTURE)GetResource( strName ); } - LPDIRECT3DVOLUMETEXTURE GetVolumeTexture( const CHAR* strName ) const - { return (LPDIRECT3DVOLUMETEXTURE)GetResource( strName ); } + LPDIRECT3DVOLUMETEXTURE GetVolumeTexture( const CHAR* strName ) const + { return (LPDIRECT3DVOLUMETEXTURE)GetResource( strName ); } - LPDIRECT3DVERTEXBUFFER GetVertexBuffer( const CHAR* strName ) const - { return (LPDIRECT3DVERTEXBUFFER)GetResource( strName ); } + LPDIRECT3DVERTEXBUFFER GetVertexBuffer( const CHAR* strName ) const + { return (LPDIRECT3DVERTEXBUFFER)GetResource( strName ); } #ifdef _XBOX1 - LPDIRECT3DPUSHBUFFER8 GetPushBuffer( const CHAR* strName ) const - { return (LPDIRECT3DPUSHBUFFER8)GetResource( strName ); } + LPDIRECT3DPUSHBUFFER8 GetPushBuffer( const CHAR* strName ) const + { return (LPDIRECT3DPUSHBUFFER8)GetResource( strName ); } #endif - // Constructor/destructor - PackedResource(); - ~PackedResource(); + // Constructor/destructor + PackedResource(); + ~PackedResource(); }; #endif RARCH_XDK_RESOURCE_H diff --git a/xdk/xdk_xinput_input.c b/xdk/xdk_xinput_input.c index c786c2564c..38a381ecb1 100644 --- a/xdk/xdk_xinput_input.c +++ b/xdk/xdk_xinput_input.c @@ -84,12 +84,12 @@ const unsigned int platform_keys_size = sizeof(platform_keys); static void xdk_input_poll(void *data) { (void)data; - + pads_connected = 0; #if defined(_XBOX1) unsigned int dwInsertions, dwRemovals; - + XGetDeviceChanges(XDEVICE_TYPE_GAMEPAD, reinterpret_cast(&dwInsertions), reinterpret_cast(&dwRemovals)); for (unsigned i = 0; i < MAX_PADS; i++) @@ -107,7 +107,7 @@ static void xdk_input_poll(void *data) if(gamepads[i]) XInputClose(gamepads[i]); - gamepads[i] = NULL; + gamepads[i] = NULL; } // handle inserted devices @@ -122,7 +122,7 @@ static void xdk_input_poll(void *data) m_pollingParameters.bOutputInterval = 8; gamepads[i] = XInputOpen(XDEVICE_TYPE_GAMEPAD, i, XDEVICE_NO_SLOT, NULL); } - + if (gamepads[i]) { // if the controller is removed after XGetDeviceChanges but before @@ -260,7 +260,7 @@ static void xdk_set_default_keybind_lut(unsigned device, unsigned port) (void)port; for (int i = 0; i < RARCH_CUSTOM_BIND_LIST_END; i++) - rarch_default_keybind_lut[i] = platform_keys[i].joykey; + rarch_default_keybind_lut[i] = platform_keys[i].joykey; } static void xdk_input_set_analog_dpad_mapping(unsigned device, unsigned map_dpad_enum, unsigned controller_id) @@ -299,16 +299,16 @@ static void *xdk_input_init(void) XInitDevices(0, NULL); dwDeviceMask = XGetDevices(XDEVICE_TYPE_GAMEPAD); - + //Check the device status switch(XGetDeviceEnumerationStatus()) { case XDEVICE_ENUMERATION_IDLE: RARCH_LOG("Input state status: XDEVICE_ENUMERATION_IDLE\n"); - break; + break; case XDEVICE_ENUMERATION_BUSY: - RARCH_LOG("Input state status: XDEVICE_ENUMERATION_BUSY\n"); - break; + RARCH_LOG("Input state status: XDEVICE_ENUMERATION_BUSY\n"); + break; } while(XGetDeviceEnumerationStatus() == XDEVICE_ENUMERATION_BUSY) {}