Celebrate the death of the xbox. Merge.
This commit is contained in:
+4
-8
@@ -230,17 +230,13 @@ struct BannerTexture: public RageTexture
|
|||||||
m_iTextureWidth = m_iImageWidth = m_pImage->w;
|
m_iTextureWidth = m_iImageWidth = m_pImage->w;
|
||||||
m_iTextureHeight = m_iImageHeight = m_pImage->h;
|
m_iTextureHeight = m_iImageHeight = m_pImage->h;
|
||||||
|
|
||||||
/* Find a supported texture format. If it happens to match the stored
|
/* Find a supported texture format. If it happens to match the stored
|
||||||
* file, we won't have to do any conversion here, and that'll happen often
|
* file, we won't have to do any conversion here, and that'll happen
|
||||||
* with paletted images. */
|
* often with paletted images. */
|
||||||
#if !defined(XBOX)
|
|
||||||
PixelFormat pf = m_pImage->format->BitsPerPixel == 8? PixelFormat_PAL: PixelFormat_RGB5A1;
|
PixelFormat pf = m_pImage->format->BitsPerPixel == 8? PixelFormat_PAL: PixelFormat_RGB5A1;
|
||||||
if( !DISPLAY->SupportsTextureFormat(pf) )
|
if( !DISPLAY->SupportsTextureFormat(pf) )
|
||||||
pf = PixelFormat_RGBA4;
|
pf = PixelFormat_RGBA4;
|
||||||
#else
|
|
||||||
// xbox display currently supports only rgba8
|
|
||||||
PixelFormat pf = PixelFormat_RGBA8;
|
|
||||||
#endif
|
|
||||||
ASSERT( DISPLAY->SupportsTextureFormat(pf) );
|
ASSERT( DISPLAY->SupportsTextureFormat(pf) );
|
||||||
|
|
||||||
ASSERT(m_pImage);
|
ASSERT(m_pImage);
|
||||||
|
|||||||
+2
-4
@@ -27,7 +27,7 @@ struct Impl
|
|||||||
};
|
};
|
||||||
static Impl *pImpl = NULL;
|
static Impl *pImpl = NULL;
|
||||||
|
|
||||||
#if defined(_MSC_VER) || defined (_XBOX)
|
#if defined(_MSC_VER)
|
||||||
/* "interaction between '_setjmp' and C++ object destruction is non-portable"
|
/* "interaction between '_setjmp' and C++ object destruction is non-portable"
|
||||||
* We don't care; we'll throw a fatal exception immediately anyway. */
|
* We don't care; we'll throw a fatal exception immediately anyway. */
|
||||||
#pragma warning (disable : 4611)
|
#pragma warning (disable : 4611)
|
||||||
@@ -973,9 +973,7 @@ LuaFunction( VersionTime, (RString) version_time );
|
|||||||
static RString GetOSName()
|
static RString GetOSName()
|
||||||
{
|
{
|
||||||
RString system;
|
RString system;
|
||||||
#if defined(XBOX)
|
#if defined(WIN32)
|
||||||
system = "Xbox";
|
|
||||||
#elif defined(WIN32) && !defined(XBOX)
|
|
||||||
system = "Windows";
|
system = "Windows";
|
||||||
#elif defined(LINUX)
|
#elif defined(LINUX)
|
||||||
system = "Linux";
|
system = "Linux";
|
||||||
|
|||||||
+2
-116
@@ -17,16 +17,11 @@
|
|||||||
#include <D3dx8math.h>
|
#include <D3dx8math.h>
|
||||||
#include <D3DX8Core.h>
|
#include <D3DX8Core.h>
|
||||||
|
|
||||||
#if !defined(XBOX)
|
|
||||||
#include "archutils/Win32/GraphicsWindow.h"
|
#include "archutils/Win32/GraphicsWindow.h"
|
||||||
#else
|
|
||||||
#include "archutils/Xbox/GraphicsWindow.h"
|
|
||||||
#include "archutils/Xbox/VirtualMemory.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Static libraries
|
// Static libraries
|
||||||
// load Windows D3D8 dynamically
|
// load Windows D3D8 dynamically
|
||||||
#if defined(_MSC_VER) && !defined(_XBOX)
|
#if defined(_MSC_VER)
|
||||||
#pragma comment(lib, "D3dx8.lib")
|
#pragma comment(lib, "D3dx8.lib")
|
||||||
#pragma comment(lib, "Dxerr8.lib")
|
#pragma comment(lib, "Dxerr8.lib")
|
||||||
#endif
|
#endif
|
||||||
@@ -42,9 +37,7 @@ RString GetErrorString( HRESULT hr )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Globals
|
// Globals
|
||||||
#if !defined(XBOX)
|
|
||||||
HMODULE g_D3D8_Module = NULL;
|
HMODULE g_D3D8_Module = NULL;
|
||||||
#endif
|
|
||||||
LPDIRECT3D8 g_pd3d = NULL;
|
LPDIRECT3D8 g_pd3d = NULL;
|
||||||
LPDIRECT3DDEVICE8 g_pd3dDevice = NULL;
|
LPDIRECT3DDEVICE8 g_pd3dDevice = NULL;
|
||||||
D3DCAPS8 g_DeviceCaps;
|
D3DCAPS8 g_DeviceCaps;
|
||||||
@@ -84,12 +77,8 @@ static void SetPalette( unsigned TexResource )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load it.
|
// Load it.
|
||||||
#if !defined(XBOX)
|
|
||||||
TexturePalette& pal = g_TexResourceToTexturePalette[TexResource];
|
TexturePalette& pal = g_TexResourceToTexturePalette[TexResource];
|
||||||
g_pd3dDevice->SetPaletteEntries( iPalIndex, pal.p );
|
g_pd3dDevice->SetPaletteEntries( iPalIndex, pal.p );
|
||||||
#else
|
|
||||||
ASSERT(0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
g_TexResourceToPaletteIndex[TexResource] = iPalIndex;
|
g_TexResourceToPaletteIndex[TexResource] = iPalIndex;
|
||||||
}
|
}
|
||||||
@@ -106,11 +95,7 @@ static void SetPalette( unsigned TexResource )
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(XBOX)
|
|
||||||
g_pd3dDevice->SetCurrentTexturePalette( iPalIndex );
|
g_pd3dDevice->SetCurrentTexturePalette( iPalIndex );
|
||||||
#else
|
|
||||||
ASSERT(0);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define D3DFVF_RageSpriteVertex (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_DIFFUSE|D3DFVF_TEX1)
|
#define D3DFVF_RageSpriteVertex (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_DIFFUSE|D3DFVF_TEX1)
|
||||||
@@ -178,11 +163,7 @@ static D3DFORMAT D3DFORMATS[NUM_PixelFormat] =
|
|||||||
D3DFMT_A4R4G4B4,
|
D3DFMT_A4R4G4B4,
|
||||||
D3DFMT_A1R5G5B5,
|
D3DFMT_A1R5G5B5,
|
||||||
D3DFMT_X1R5G5B5,
|
D3DFMT_X1R5G5B5,
|
||||||
#if defined(XBOX)
|
|
||||||
D3DFMT_UNKNOWN, // no RGB
|
|
||||||
#else
|
|
||||||
D3DFMT_R8G8B8,
|
D3DFMT_R8G8B8,
|
||||||
#endif
|
|
||||||
D3DFMT_P8,
|
D3DFMT_P8,
|
||||||
D3DFMT_UNKNOWN, // no BGR
|
D3DFMT_UNKNOWN, // no BGR
|
||||||
D3DFMT_UNKNOWN, // no ABGR
|
D3DFMT_UNKNOWN, // no ABGR
|
||||||
@@ -214,9 +195,7 @@ RString RageDisplay_D3D::Init( const VideoModeParams &p, bool bAllowUnaccelerate
|
|||||||
|
|
||||||
typedef IDirect3D8 * (WINAPI * Direct3DCreate8_t) (UINT SDKVersion);
|
typedef IDirect3D8 * (WINAPI * Direct3DCreate8_t) (UINT SDKVersion);
|
||||||
Direct3DCreate8_t pDirect3DCreate8;
|
Direct3DCreate8_t pDirect3DCreate8;
|
||||||
#if defined(XBOX)
|
|
||||||
pDirect3DCreate8 = Direct3DCreate8;
|
|
||||||
#else
|
|
||||||
g_D3D8_Module = LoadLibrary("D3D8.dll");
|
g_D3D8_Module = LoadLibrary("D3D8.dll");
|
||||||
if(!g_D3D8_Module)
|
if(!g_D3D8_Module)
|
||||||
return D3D_NOT_INSTALLED.GetValue() + "\n" + D3D_URL;
|
return D3D_NOT_INSTALLED.GetValue() + "\n" + D3D_URL;
|
||||||
@@ -227,7 +206,6 @@ RString RageDisplay_D3D::Init( const VideoModeParams &p, bool bAllowUnaccelerate
|
|||||||
LOG->Trace( "Direct3DCreate8 not found" );
|
LOG->Trace( "Direct3DCreate8 not found" );
|
||||||
return D3D_NOT_INSTALLED.GetValue();
|
return D3D_NOT_INSTALLED.GetValue();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
g_pd3d = pDirect3DCreate8( D3D_SDK_VERSION );
|
g_pd3d = pDirect3DCreate8( D3D_SDK_VERSION );
|
||||||
if(!g_pd3d)
|
if(!g_pd3d)
|
||||||
@@ -294,13 +272,11 @@ RageDisplay_D3D::~RageDisplay_D3D()
|
|||||||
/* Even after we call Release(), D3D may still affect our window. It seems
|
/* Even after we call Release(), D3D may still affect our window. It seems
|
||||||
* to subclass the window, and never release it. Free the DLL after
|
* to subclass the window, and never release it. Free the DLL after
|
||||||
* destroying the window. */
|
* destroying the window. */
|
||||||
#if !defined(XBOX)
|
|
||||||
if( g_D3D8_Module )
|
if( g_D3D8_Module )
|
||||||
{
|
{
|
||||||
FreeLibrary( g_D3D8_Module );
|
FreeLibrary( g_D3D8_Module );
|
||||||
g_D3D8_Module = NULL;
|
g_D3D8_Module = NULL;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageDisplay_D3D::GetDisplayResolutions( DisplayResolutions &out ) const
|
void RageDisplay_D3D::GetDisplayResolutions( DisplayResolutions &out ) const
|
||||||
@@ -334,9 +310,7 @@ D3DFORMAT FindBackBufferType(bool bWindowed, int iBPP)
|
|||||||
}
|
}
|
||||||
if( iBPP == 32 || bWindowed )
|
if( iBPP == 32 || bWindowed )
|
||||||
{
|
{
|
||||||
#if !defined(XBOX)
|
|
||||||
vBackBufferFormats.push_back( D3DFMT_R8G8B8 );
|
vBackBufferFormats.push_back( D3DFMT_R8G8B8 );
|
||||||
#endif
|
|
||||||
vBackBufferFormats.push_back( D3DFMT_X8R8G8B8 );
|
vBackBufferFormats.push_back( D3DFMT_X8R8G8B8 );
|
||||||
vBackBufferFormats.push_back( D3DFMT_A8R8G8B8 );
|
vBackBufferFormats.push_back( D3DFMT_A8R8G8B8 );
|
||||||
}
|
}
|
||||||
@@ -383,13 +357,8 @@ RString SetD3DParams( bool &bNewDeviceOut )
|
|||||||
HRESULT hr = g_pd3d->CreateDevice(
|
HRESULT hr = g_pd3d->CreateDevice(
|
||||||
D3DADAPTER_DEFAULT,
|
D3DADAPTER_DEFAULT,
|
||||||
D3DDEVTYPE_HAL,
|
D3DDEVTYPE_HAL,
|
||||||
#if !defined(XBOX)
|
|
||||||
GraphicsWindow::GetHwnd(),
|
GraphicsWindow::GetHwnd(),
|
||||||
D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED,
|
D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED,
|
||||||
#else
|
|
||||||
NULL,
|
|
||||||
D3DCREATE_HARDWARE_VERTEXPROCESSING,
|
|
||||||
#endif
|
|
||||||
&g_d3dpp,
|
&g_d3dpp,
|
||||||
&g_pd3dDevice );
|
&g_pd3dDevice );
|
||||||
if( FAILED(hr) )
|
if( FAILED(hr) )
|
||||||
@@ -506,11 +475,7 @@ static void SetPresentParametersFromVideoModeParams( const VideoModeParams &p, D
|
|||||||
pD3Dpp->BackBufferCount = 1;
|
pD3Dpp->BackBufferCount = 1;
|
||||||
pD3Dpp->MultiSampleType = D3DMULTISAMPLE_NONE;
|
pD3Dpp->MultiSampleType = D3DMULTISAMPLE_NONE;
|
||||||
pD3Dpp->SwapEffect = D3DSWAPEFFECT_DISCARD;
|
pD3Dpp->SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||||
#if !defined(XBOX)
|
|
||||||
pD3Dpp->hDeviceWindow = GraphicsWindow::GetHwnd();
|
pD3Dpp->hDeviceWindow = GraphicsWindow::GetHwnd();
|
||||||
#else
|
|
||||||
pD3Dpp->hDeviceWindow = NULL;
|
|
||||||
#endif
|
|
||||||
pD3Dpp->Windowed = p.windowed;
|
pD3Dpp->Windowed = p.windowed;
|
||||||
pD3Dpp->EnableAutoDepthStencil = TRUE;
|
pD3Dpp->EnableAutoDepthStencil = TRUE;
|
||||||
pD3Dpp->AutoDepthStencilFormat = D3DFMT_D16;
|
pD3Dpp->AutoDepthStencilFormat = D3DFMT_D16;
|
||||||
@@ -520,25 +485,9 @@ static void SetPresentParametersFromVideoModeParams( const VideoModeParams &p, D
|
|||||||
else
|
else
|
||||||
pD3Dpp->FullScreen_PresentationInterval = p.vsync ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
|
pD3Dpp->FullScreen_PresentationInterval = p.vsync ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||||
|
|
||||||
#if !defined(XBOX)
|
|
||||||
pD3Dpp->FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
|
pD3Dpp->FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
|
||||||
if( !p.windowed && p.rate != REFRESH_DEFAULT )
|
if( !p.windowed && p.rate != REFRESH_DEFAULT )
|
||||||
pD3Dpp->FullScreen_RefreshRateInHz = p.rate;
|
pD3Dpp->FullScreen_RefreshRateInHz = p.rate;
|
||||||
#else
|
|
||||||
if( XGetVideoStandard() == XC_VIDEO_STANDARD_PAL_I )
|
|
||||||
{
|
|
||||||
// Get supported video flags.
|
|
||||||
DWORD VideoFlags = XGetVideoFlags();
|
|
||||||
|
|
||||||
// Set pal60 if available.
|
|
||||||
if( VideoFlags & XC_VIDEO_FLAGS_PAL_60Hz )
|
|
||||||
pD3Dpp->FullScreen_RefreshRateInHz = 60;
|
|
||||||
else
|
|
||||||
pD3Dpp->FullScreen_RefreshRateInHz = 50;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
pD3Dpp->FullScreen_RefreshRateInHz = 60;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
pD3Dpp->Flags = 0;
|
pD3Dpp->Flags = 0;
|
||||||
|
|
||||||
@@ -556,9 +505,6 @@ static void SetPresentParametersFromVideoModeParams( const VideoModeParams &p, D
|
|||||||
RString RageDisplay_D3D::TryVideoMode( const VideoModeParams &_p, bool &bNewDeviceOut )
|
RString RageDisplay_D3D::TryVideoMode( const VideoModeParams &_p, bool &bNewDeviceOut )
|
||||||
{
|
{
|
||||||
VideoModeParams p = _p;
|
VideoModeParams p = _p;
|
||||||
#if defined(XBOX)
|
|
||||||
p.windowed = false;
|
|
||||||
#endif
|
|
||||||
LOG->Warn( "RageDisplay_D3D::TryVideoMode( %d, %d, %d, %d, %d, %d )", p.windowed, p.width, p.height, p.bpp, p.rate, p.vsync );
|
LOG->Warn( "RageDisplay_D3D::TryVideoMode( %d, %d, %d, %d, %d, %d )", p.windowed, p.width, p.height, p.bpp, p.rate, p.vsync );
|
||||||
|
|
||||||
if( FindBackBufferType( p.windowed, p.bpp ) == D3DFMT_UNKNOWN ) // no possible back buffer formats
|
if( FindBackBufferType( p.windowed, p.bpp ) == D3DFMT_UNKNOWN ) // no possible back buffer formats
|
||||||
@@ -571,11 +517,6 @@ RString RageDisplay_D3D::TryVideoMode( const VideoModeParams &_p, bool &bNewDevi
|
|||||||
|
|
||||||
SetPresentParametersFromVideoModeParams( p, &g_d3dpp );
|
SetPresentParametersFromVideoModeParams( p, &g_d3dpp );
|
||||||
|
|
||||||
#if defined(XBOX)
|
|
||||||
if( D3D__pDevice )
|
|
||||||
g_pd3dDevice = D3D__pDevice;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Display the window immediately, so we don't display the desktop ...
|
// Display the window immediately, so we don't display the desktop ...
|
||||||
while( 1 )
|
while( 1 )
|
||||||
{
|
{
|
||||||
@@ -612,14 +553,6 @@ void RageDisplay_D3D::ResolutionChanged()
|
|||||||
{
|
{
|
||||||
//LOG->Warn( "RageDisplay_D3D::ResolutionChanged" );
|
//LOG->Warn( "RageDisplay_D3D::ResolutionChanged" );
|
||||||
|
|
||||||
#if defined(XBOX)
|
|
||||||
VideoModeParams p = GetActualVideoModeParams();
|
|
||||||
D3DVIEWPORT8 viewData = { 0, 0, p.width, p.height, 0.f, 1.f };
|
|
||||||
g_pd3dDevice->SetViewport( &viewData );
|
|
||||||
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,
|
|
||||||
D3DCOLOR_XRGB(0,0,0), 1.0f, 0x00000000 );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
RageDisplay::ResolutionChanged();
|
RageDisplay::ResolutionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -632,7 +565,6 @@ bool RageDisplay_D3D::BeginFrame()
|
|||||||
{
|
{
|
||||||
GraphicsWindow::Update();
|
GraphicsWindow::Update();
|
||||||
|
|
||||||
#if !defined(XBOX)
|
|
||||||
switch( g_pd3dDevice->TestCooperativeLevel() )
|
switch( g_pd3dDevice->TestCooperativeLevel() )
|
||||||
{
|
{
|
||||||
case D3DERR_DEVICELOST:
|
case D3DERR_DEVICELOST:
|
||||||
@@ -647,7 +579,6 @@ bool RageDisplay_D3D::BeginFrame()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,
|
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,
|
||||||
D3DCOLOR_XRGB(0,0,0), 1.0f, 0x00000000 );
|
D3DCOLOR_XRGB(0,0,0), 1.0f, 0x00000000 );
|
||||||
@@ -670,16 +601,6 @@ void RageDisplay_D3D::EndFrame()
|
|||||||
|
|
||||||
bool RageDisplay_D3D::SupportsTextureFormat( PixelFormat pixfmt, bool realtime )
|
bool RageDisplay_D3D::SupportsTextureFormat( PixelFormat pixfmt, bool realtime )
|
||||||
{
|
{
|
||||||
#if defined(XBOX)
|
|
||||||
/* Lazy... Xbox handles paletted textures completely differently than
|
|
||||||
* regular D3D. It's not worth writing a bunch of code to handle it.
|
|
||||||
* Paletted textures result in worse cache efficiency anyway (see "Xbox
|
|
||||||
* Palettized Texture Performance" in XDK). So, just force 32bit ARGB textures.
|
|
||||||
* -Chris
|
|
||||||
* This is also needed for XGSwizzleRect(). */
|
|
||||||
return pixfmt == PixelFormat_RGBA8;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Some cards (Savage) don't support alpha in palettes.
|
// Some cards (Savage) don't support alpha in palettes.
|
||||||
// Don't allow paletted textures if this is the case.
|
// Don't allow paletted textures if this is the case.
|
||||||
if( pixfmt == PixelFormat_PAL && !(g_DeviceCaps.TextureCaps & D3DPTEXTURECAPS_ALPHAPALETTE) )
|
if( pixfmt == PixelFormat_PAL && !(g_DeviceCaps.TextureCaps & D3DPTEXTURECAPS_ALPHAPALETTE) )
|
||||||
@@ -707,9 +628,6 @@ bool RageDisplay_D3D::SupportsThreadedRendering()
|
|||||||
|
|
||||||
RageSurface* RageDisplay_D3D::CreateScreenshot()
|
RageSurface* RageDisplay_D3D::CreateScreenshot()
|
||||||
{
|
{
|
||||||
#if defined(XBOX)
|
|
||||||
return NULL;
|
|
||||||
#else
|
|
||||||
// Get the back buffer.
|
// Get the back buffer.
|
||||||
IDirect3DSurface8* pSurface;
|
IDirect3DSurface8* pSurface;
|
||||||
g_pd3dDevice->GetBackBuffer( 0, D3DBACKBUFFER_TYPE_MONO, &pSurface );
|
g_pd3dDevice->GetBackBuffer( 0, D3DBACKBUFFER_TYPE_MONO, &pSurface );
|
||||||
@@ -756,7 +674,6 @@ RageSurface* RageDisplay_D3D::CreateScreenshot()
|
|||||||
pCopy->Release();
|
pCopy->Release();
|
||||||
|
|
||||||
return SurfaceCopy;
|
return SurfaceCopy;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoModeParams RageDisplay_D3D::GetActualVideoModeParams() const
|
VideoModeParams RageDisplay_D3D::GetActualVideoModeParams() const
|
||||||
@@ -1429,15 +1346,6 @@ unsigned RageDisplay_D3D::CreateTexture(
|
|||||||
IDirect3DTexture8* pTex;
|
IDirect3DTexture8* pTex;
|
||||||
hr = g_pd3dDevice->CreateTexture( power_of_two(img->w), power_of_two(img->h), 1, 0, D3DFORMATS[pixfmt], D3DPOOL_MANAGED, &pTex );
|
hr = g_pd3dDevice->CreateTexture( power_of_two(img->w), power_of_two(img->h), 1, 0, D3DFORMATS[pixfmt], D3DPOOL_MANAGED, &pTex );
|
||||||
|
|
||||||
#if defined(XBOX)
|
|
||||||
while(hr == E_OUTOFMEMORY)
|
|
||||||
{
|
|
||||||
if(!vmem_Manager.DecommitLRU())
|
|
||||||
break;
|
|
||||||
hr = g_pd3dDevice->CreateTexture( power_of_two(img->w), power_of_two(img->h), 1, 0, D3DFORMATS[pixfmt], D3DPOOL_MANAGED, &pTex );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if( FAILED(hr) )
|
if( FAILED(hr) )
|
||||||
RageException::Throw( "CreateTexture(%i,%i,%s) failed: %s",
|
RageException::Throw( "CreateTexture(%i,%i,%s) failed: %s",
|
||||||
img->w, img->h, PixelFormatToString(pixfmt).c_str(), GetErrorString(hr).c_str() );
|
img->w, img->h, PixelFormatToString(pixfmt).c_str(), GetErrorString(hr).c_str() );
|
||||||
@@ -1490,27 +1398,6 @@ void RageDisplay_D3D::UpdateTexture(
|
|||||||
ASSERT( yoffset+height <= int(desc.Height) );
|
ASSERT( yoffset+height <= int(desc.Height) );
|
||||||
|
|
||||||
// Copy bits
|
// Copy bits
|
||||||
#if defined(XBOX)
|
|
||||||
RageSurface *Texture = CreateSurface( width, height, 32,
|
|
||||||
Swap32BE( 0x0000FF00 ),
|
|
||||||
Swap32BE( 0x00FF0000 ),
|
|
||||||
Swap32BE( 0xFF000000 ),
|
|
||||||
Swap32BE( 0x000000FF ) );
|
|
||||||
|
|
||||||
RageSurfaceUtils::Blit( img, Texture, width, height );
|
|
||||||
|
|
||||||
// Xbox textures need to be swizzled
|
|
||||||
XGSwizzleRect(
|
|
||||||
Texture->pixels, // pSource,
|
|
||||||
Texture->pitch, // Pitch,
|
|
||||||
NULL, // pRect,
|
|
||||||
lr.pBits, // pDest,
|
|
||||||
Texture->w, // Width,
|
|
||||||
Texture->h, // Height,
|
|
||||||
NULL, // pPoint,
|
|
||||||
Texture->format->BytesPerPixel ); //BytesPerPixel
|
|
||||||
delete Texture;
|
|
||||||
#else
|
|
||||||
int texpixfmt;
|
int texpixfmt;
|
||||||
for(texpixfmt = 0; texpixfmt < NUM_PixelFormat; ++texpixfmt)
|
for(texpixfmt = 0; texpixfmt < NUM_PixelFormat; ++texpixfmt)
|
||||||
if(D3DFORMATS[texpixfmt] == desc.Format) break;
|
if(D3DFORMATS[texpixfmt] == desc.Format) break;
|
||||||
@@ -1521,7 +1408,6 @@ void RageDisplay_D3D::UpdateTexture(
|
|||||||
RageSurfaceUtils::Blit( img, Texture, width, height );
|
RageSurfaceUtils::Blit( img, Texture, width, height );
|
||||||
|
|
||||||
delete Texture;
|
delete Texture;
|
||||||
#endif
|
|
||||||
|
|
||||||
pTex->UnlockRect( 0 );
|
pTex->UnlockRect( 0 );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
#include "RageUtil.h"
|
#include "RageUtil.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#if defined(_WINDOWS) || defined(_XBOX)
|
#if defined(_WINDOWS)
|
||||||
#include "zlib/zlib.h"
|
#include "zlib/zlib.h"
|
||||||
#if defined(_MSC_VER) && !defined(_XBOX)
|
#if defined(_MSC_VER)
|
||||||
#pragma comment(lib, "zlib/zdll.lib")
|
#pragma comment(lib, "zlib/zdll.lib")
|
||||||
#endif
|
#endif
|
||||||
#elif defined(MACOSX)
|
#elif defined(MACOSX)
|
||||||
|
|||||||
@@ -16,9 +16,7 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#else
|
#else
|
||||||
#include "archutils/Win32/ErrorStrings.h"
|
#include "archutils/Win32/ErrorStrings.h"
|
||||||
#if !defined(_XBOX)
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif // !defined(_XBOX)
|
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#endif // !defined(WIN32)
|
#endif // !defined(WIN32)
|
||||||
|
|
||||||
|
|||||||
@@ -12,57 +12,13 @@
|
|||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#else
|
#else
|
||||||
#if !defined(_XBOX)
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_XBOX)
|
|
||||||
/* Wrappers for low-level file functions, to work around Xbox issues: */
|
|
||||||
int DoMkdir( const RString &sPath, int perm )
|
|
||||||
{
|
|
||||||
return mkdir( DoPathReplace(sPath), perm );
|
|
||||||
}
|
|
||||||
|
|
||||||
int DoOpen( const RString &sPath, int flags, int perm )
|
|
||||||
{
|
|
||||||
return open( DoPathReplace(sPath), flags, perm );
|
|
||||||
}
|
|
||||||
|
|
||||||
int DoStat( const RString &sPath, struct stat *st )
|
|
||||||
{
|
|
||||||
return stat( DoPathReplace(sPath), st );
|
|
||||||
}
|
|
||||||
|
|
||||||
int DoRename( const RString &sOldPath, const RString &sNewPath )
|
|
||||||
{
|
|
||||||
return rename( DoPathReplace(sOldPath), DoPathReplace(sNewPath) );
|
|
||||||
}
|
|
||||||
|
|
||||||
int DoRemove( const RString &sPath )
|
|
||||||
{
|
|
||||||
return remove( DoPathReplace(sPath) );
|
|
||||||
}
|
|
||||||
|
|
||||||
int DoRmdir( const RString &sPath )
|
|
||||||
{
|
|
||||||
return rmdir( DoPathReplace(sPath) );
|
|
||||||
}
|
|
||||||
|
|
||||||
HANDLE DoFindFirstFile( const RString &sPath, WIN32_FIND_DATA *fd )
|
|
||||||
{
|
|
||||||
return FindFirstFile( DoPathReplace(sPath), fd );
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
RString DoPathReplace(const RString &sPath)
|
RString DoPathReplace(const RString &sPath)
|
||||||
{
|
{
|
||||||
RString TempPath = sPath;
|
RString TempPath = sPath;
|
||||||
#if defined(XBOX)
|
|
||||||
TempPath.Replace( "//", "\\" );
|
|
||||||
TempPath.Replace( "/", "\\" );
|
|
||||||
#endif
|
|
||||||
return TempPath;
|
return TempPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,9 +28,9 @@ static bool WinMoveFileInternal( const RString &sOldPath, const RString &sNewPat
|
|||||||
{
|
{
|
||||||
static bool Win9x = false;
|
static bool Win9x = false;
|
||||||
|
|
||||||
/* Windows botches rename: it returns error if the file exists. In NT,
|
/* Windows botches rename: it returns error if the file exists. In NT,
|
||||||
* we can use MoveFileEx( new, old, MOVEFILE_REPLACE_EXISTING ) (though I
|
* we can use MoveFileEx( new, old, MOVEFILE_REPLACE_EXISTING ) (though I
|
||||||
* don't know if it has similar atomicity guarantees to rename). In
|
* don't know if it has similar atomicity guarantees to rename). In
|
||||||
* 9x, we're screwed, so just delete any existing file (we aren't going
|
* 9x, we're screwed, so just delete any existing file (we aren't going
|
||||||
* to be robust on 9x anyway). */
|
* to be robust on 9x anyway). */
|
||||||
if( !Win9x )
|
if( !Win9x )
|
||||||
@@ -118,15 +74,15 @@ bool WinMoveFile( RString sOldPath, RString sNewPath )
|
|||||||
/* mkdir -p. Doesn't fail if Path already exists and is a directory. */
|
/* mkdir -p. Doesn't fail if Path already exists and is a directory. */
|
||||||
bool CreateDirectories( RString Path )
|
bool CreateDirectories( RString Path )
|
||||||
{
|
{
|
||||||
/* XXX: handle "//foo/bar" paths in Windows */
|
// XXX: handle "//foo/bar" paths in Windows
|
||||||
vector<RString> parts;
|
vector<RString> parts;
|
||||||
RString curpath;
|
RString curpath;
|
||||||
|
|
||||||
/* If Path is absolute, add the initial slash ("ignore empty" will remove it). */
|
// If Path is absolute, add the initial slash ("ignore empty" will remove it).
|
||||||
if( Path.Left(1) == "/" )
|
if( Path.Left(1) == "/" )
|
||||||
curpath = "/";
|
curpath = "/";
|
||||||
|
|
||||||
/* Ignore empty, so eg. "/foo/bar//baz" doesn't try to create "/foo/bar" twice. */
|
// Ignore empty, so eg. "/foo/bar//baz" doesn't try to create "/foo/bar" twice.
|
||||||
split( Path, "/", parts, true );
|
split( Path, "/", parts, true );
|
||||||
|
|
||||||
for(unsigned i = 0; i < parts.size(); ++i)
|
for(unsigned i = 0; i < parts.size(); ++i)
|
||||||
@@ -189,10 +145,10 @@ void DirectFilenameDB::SetRoot( RString root_ )
|
|||||||
{
|
{
|
||||||
root = root_;
|
root = root_;
|
||||||
|
|
||||||
/* "\abcd\" -> "/abcd/": */
|
// "\abcd\" -> "/abcd/":
|
||||||
root.Replace( "\\", "/" );
|
root.Replace( "\\", "/" );
|
||||||
|
|
||||||
/* "/abcd/" -> "/abcd": */
|
// "/abcd/" -> "/abcd":
|
||||||
if( root.Right(1) == "/" )
|
if( root.Right(1) == "/" )
|
||||||
root.erase( root.size()-1, 1 );
|
root.erase( root.size()-1, 1 );
|
||||||
}
|
}
|
||||||
@@ -237,7 +193,7 @@ void DirectFilenameDB::CacheFile( const RString &sPath )
|
|||||||
// If it's a broken symlink, ignore it. Otherwise, warn.
|
// If it's a broken symlink, ignore it. Otherwise, warn.
|
||||||
// Huh?
|
// Huh?
|
||||||
WARN( ssprintf("File '%s' is gone! (%s)",
|
WARN( ssprintf("File '%s' is gone! (%s)",
|
||||||
sPath.c_str(), strerror(iError)) );
|
sPath.c_str(), strerror(iError)) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -255,17 +211,10 @@ void DirectFilenameDB::PopulateFileSet( FileSet &fs, const RString &path )
|
|||||||
{
|
{
|
||||||
RString sPath = path;
|
RString sPath = path;
|
||||||
|
|
||||||
#if defined(XBOX)
|
// Resolve path cases (path/Path -> PATH/path).
|
||||||
/* Xbox doesn't handle path names which end with ".", which are used when using an
|
|
||||||
* alternative song directory */
|
|
||||||
if( sPath.size() > 0 && sPath.Right(1) == "." )
|
|
||||||
sPath.erase( sPath.size() - 1 );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Resolve path cases (path/Path -> PATH/path). */
|
|
||||||
ResolvePath( sPath );
|
ResolvePath( sPath );
|
||||||
|
|
||||||
fs.age.GetDeltaTime(); /* reset */
|
fs.age.GetDeltaTime(); // reset
|
||||||
fs.files.clear();
|
fs.files.clear();
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
|
|||||||
@@ -5,15 +5,6 @@
|
|||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#if defined(_XBOX)
|
|
||||||
int DoMkdir( const RString &sPath, int perm );
|
|
||||||
int DoOpen( const RString &sPath, int flags, int perm );
|
|
||||||
int DoStat( const RString &sPath, struct stat *st );
|
|
||||||
int DoRename( const RString &sOldPath, const RString &sNewPath );
|
|
||||||
int DoRemove( const RString &sPath );
|
|
||||||
int DoRmdir( const RString &sPath );
|
|
||||||
HANDLE DoFindFirstFile( const RString &sPath, WIN32_FIND_DATA *fd );
|
|
||||||
#else
|
|
||||||
#define DoOpen open
|
#define DoOpen open
|
||||||
#define DoStat stat
|
#define DoStat stat
|
||||||
#define DoMkdir mkdir
|
#define DoMkdir mkdir
|
||||||
@@ -21,7 +12,6 @@ HANDLE DoFindFirstFile( const RString &sPath, WIN32_FIND_DATA *fd );
|
|||||||
#define DoRename rename
|
#define DoRename rename
|
||||||
#define DoRemove remove
|
#define DoRemove remove
|
||||||
#define DoRmdir rmdir
|
#define DoRmdir rmdir
|
||||||
#endif
|
|
||||||
RString DoPathReplace( const RString &sPath );
|
RString DoPathReplace( const RString &sPath );
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
|
|
||||||
#if defined(WIN32) && !defined(XBOX)
|
#if defined(WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#elif defined(UNIX) || defined(MACOSX)
|
#elif defined(UNIX) || defined(MACOSX)
|
||||||
#include <paths.h>
|
#include <paths.h>
|
||||||
@@ -174,11 +174,7 @@ static RageFileDriverMountpoints *g_Mountpoints = NULL;
|
|||||||
|
|
||||||
static RString GetDirOfExecutable( RString argv0 )
|
static RString GetDirOfExecutable( RString argv0 )
|
||||||
{
|
{
|
||||||
#ifdef _XBOX
|
// argv[0] can be wrong in most OS's; try to avoid using it.
|
||||||
// ???: what if it's not running from D:\?
|
|
||||||
return "D:\\";
|
|
||||||
#else
|
|
||||||
/* argv[0] can be wrong in most OS's; try to avoid using it. */
|
|
||||||
|
|
||||||
RString sPath;
|
RString sPath;
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
@@ -241,7 +237,6 @@ static RString GetDirOfExecutable( RString argv0 )
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return sPath;
|
return sPath;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ChangeToDirOfExecutable( const RString &argv0 )
|
static void ChangeToDirOfExecutable( const RString &argv0 )
|
||||||
|
|||||||
+1
-1
@@ -175,7 +175,7 @@ void RageLog::SetShowLogOutput( bool show )
|
|||||||
{
|
{
|
||||||
m_bShowLogOutput = show;
|
m_bShowLogOutput = show;
|
||||||
|
|
||||||
#if defined(WIN32) && !defined(_XBOX)
|
#if defined(WIN32)
|
||||||
if( m_bShowLogOutput )
|
if( m_bShowLogOutput )
|
||||||
{
|
{
|
||||||
// create a new console window and attach standard handles
|
// create a new console window and attach standard handles
|
||||||
|
|||||||
+1
-1
@@ -112,7 +112,7 @@ RageMatrix RageMatrix::GetTranspose() const
|
|||||||
|
|
||||||
void RageMatrixMultiply( RageMatrix* pOut, const RageMatrix* pA, const RageMatrix* pB )
|
void RageMatrixMultiply( RageMatrix* pOut, const RageMatrix* pA, const RageMatrix* pB )
|
||||||
{
|
{
|
||||||
//#if defined(_WINDOWS) || defined(_XBOX)
|
//#if defined(_WINDOWS)
|
||||||
// // <30 cycles for theirs versus >100 for ours.
|
// // <30 cycles for theirs versus >100 for ours.
|
||||||
// D3DXMatrixMultiply( (D3DMATRIX*)pOut, (D3DMATRIX*)pA, (D3DMATRIX*)pB );
|
// D3DXMatrixMultiply( (D3DMATRIX*)pOut, (D3DMATRIX*)pA, (D3DMATRIX*)pB );
|
||||||
//#else
|
//#else
|
||||||
|
|||||||
@@ -9,24 +9,16 @@
|
|||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#if defined(_WINDOWS) || defined(_XBOX) || defined(MACOSX)
|
#if defined(_WINDOWS) || defined(MACOSX)
|
||||||
#include "mad-0.15.1b/mad.h"
|
#include "mad-0.15.1b/mad.h"
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#ifdef _XBOX
|
|
||||||
#ifdef DEBUG
|
|
||||||
#pragma comment(lib, "mad-0.15.1b/xboxmad/debug/xboxmad.lib")
|
|
||||||
#else
|
|
||||||
#pragma comment(lib, "mad-0.15.1b/xboxmad/Release/xboxmad.lib")
|
|
||||||
#endif // DEBUG
|
|
||||||
#else
|
|
||||||
#pragma comment(lib, "mad-0.15.1b/msvc++/Release/libmad.lib")
|
#pragma comment(lib, "mad-0.15.1b/msvc++/Release/libmad.lib")
|
||||||
#endif // _XBOX
|
|
||||||
#endif //_MSC_VER
|
#endif //_MSC_VER
|
||||||
#else
|
#else
|
||||||
#include <mad.h>
|
#include <mad.h>
|
||||||
#endif // _WINDOWS
|
#endif // _WINDOWS
|
||||||
|
|
||||||
/* ID3 code from libid3: */
|
// ID3 code from libid3:
|
||||||
enum tagtype {
|
enum tagtype {
|
||||||
TAGTYPE_NONE = 0,
|
TAGTYPE_NONE = 0,
|
||||||
TAGTYPE_ID3V1,
|
TAGTYPE_ID3V1,
|
||||||
|
|||||||
@@ -7,24 +7,15 @@
|
|||||||
|
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
|
|
||||||
// Don't let jpeglib.h define the boolean type on Xbox.
|
|
||||||
#if defined(_XBOX)
|
|
||||||
# define HAVE_BOOLEAN
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
/* work around namespace bugs in win32/libjpeg: */
|
// work around namespace bugs in win32/libjpeg:
|
||||||
#define XMD_H
|
#define XMD_H
|
||||||
#undef FAR
|
#undef FAR
|
||||||
#include "libjpeg/jpeglib.h"
|
#include "libjpeg/jpeglib.h"
|
||||||
#include "libjpeg/jerror.h"
|
#include "libjpeg/jerror.h"
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#if !defined(XBOX)
|
|
||||||
#pragma comment(lib, "libjpeg/jpeg.lib")
|
#pragma comment(lib, "libjpeg/jpeg.lib")
|
||||||
#else
|
|
||||||
#pragma comment(lib, "libjpeg/xboxjpeg.lib")
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#pragma warning(disable: 4611) /* interaction between '_setjmp' and C++ object destruction is non-portable */
|
#pragma warning(disable: 4611) /* interaction between '_setjmp' and C++ object destruction is non-portable */
|
||||||
|
|||||||
@@ -6,25 +6,16 @@
|
|||||||
#include "RageSurface.h"
|
#include "RageSurface.h"
|
||||||
|
|
||||||
|
|
||||||
#if defined(_WINDOWS) || defined(_XBOX)
|
#if defined(_WINDOWS)
|
||||||
# include "libpng/include/png.h"
|
# include "libpng/include/png.h"
|
||||||
# if defined(_MSC_VER)
|
# if defined(_MSC_VER)
|
||||||
# if defined(_XBOX)
|
# pragma comment(lib, "libpng/lib/libpng.lib")
|
||||||
# pragma comment(lib, "libpng/lib/xboxlibpng.lib")
|
|
||||||
# else
|
|
||||||
# pragma comment(lib, "libpng/lib/libpng.lib")
|
|
||||||
# endif
|
|
||||||
# pragma warning(disable: 4611) /* interaction between '_setjmp' and C++ object destruction is non-portable */
|
# pragma warning(disable: 4611) /* interaction between '_setjmp' and C++ object destruction is non-portable */
|
||||||
# endif // _MSC_VER
|
# endif // _MSC_VER
|
||||||
#else
|
#else
|
||||||
# include <png.h>
|
# include <png.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_XBOX)
|
|
||||||
# include <malloc.h> // for alloca
|
|
||||||
# include "archutils/Xbox/VirtualMemory.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
void RageFile_png_read( png_struct *png, png_byte *p, png_size_t size )
|
void RageFile_png_read( png_struct *png, png_byte *p, png_size_t size )
|
||||||
@@ -80,16 +71,6 @@ static RageSurface *RageSurface_Load_PNG( RageFile *f, const char *fn, char erro
|
|||||||
|
|
||||||
png_struct *png = png_create_read_struct( PNG_LIBPNG_VER_STRING, &error, PNG_Error, PNG_Warning );
|
png_struct *png = png_create_read_struct( PNG_LIBPNG_VER_STRING, &error, PNG_Error, PNG_Warning );
|
||||||
|
|
||||||
#if defined(XBOX)
|
|
||||||
while(png == NULL)
|
|
||||||
{
|
|
||||||
if(!vmem_Manager.DecommitLRU())
|
|
||||||
break;
|
|
||||||
|
|
||||||
png = png_create_read_struct( PNG_LIBPNG_VER_STRING, &error, PNG_Error, PNG_Warning );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if( png == NULL )
|
if( png == NULL )
|
||||||
{
|
{
|
||||||
sprintf( errorbuf, "creating png_create_read_struct failed");
|
sprintf( errorbuf, "creating png_create_read_struct failed");
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include "RageUtil.h"
|
#include "RageUtil.h"
|
||||||
#include "RageFile.h"
|
#include "RageFile.h"
|
||||||
|
|
||||||
#undef FAR /* fix for VC */
|
#undef FAR // fix for VC
|
||||||
/** @brief A helper to get the jpeg lib. */
|
/** @brief A helper to get the jpeg lib. */
|
||||||
namespace jpeg
|
namespace jpeg
|
||||||
{
|
{
|
||||||
@@ -16,16 +16,11 @@ namespace jpeg
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pull in JPEG library here. */
|
// Pull in JPEG library here.
|
||||||
#ifdef _XBOX
|
#if defined _MSC_VER
|
||||||
#pragma comment(lib, "libjpeg/xboxjpeg.lib")
|
|
||||||
#elif defined _MSC_VER
|
|
||||||
#pragma comment(lib, "libjpeg/jpeg.lib")
|
#pragma comment(lib, "libjpeg/jpeg.lib")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define OUTPUT_BUFFER_SIZE 4096
|
#define OUTPUT_BUFFER_SIZE 4096
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,14 +6,10 @@
|
|||||||
#include "RageLog.h"
|
#include "RageLog.h"
|
||||||
#include "RageUtil.h"
|
#include "RageUtil.h"
|
||||||
|
|
||||||
#if defined(WINDOWS) || defined(_XBOX)
|
#if defined(WINDOWS)
|
||||||
#include "libpng/include/png.h"
|
#include "libpng/include/png.h"
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
# if defined(_XBOX)
|
# pragma comment(lib, "libpng/lib/libpng.lib")
|
||||||
# pragma comment(lib, "libpng/lib/xboxlibpng.lib")
|
|
||||||
# else
|
|
||||||
# pragma comment(lib, "libpng/lib/libpng.lib")
|
|
||||||
# endif
|
|
||||||
#pragma warning(disable: 4611) /* interaction between '_setjmp' and C++ object destruction is non-portable */
|
#pragma warning(disable: 4611) /* interaction between '_setjmp' and C++ object destruction is non-portable */
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -967,14 +967,10 @@ bool GetCommandlineArgument( const RString &option, RString *argument, int iInde
|
|||||||
|
|
||||||
RString GetCwd()
|
RString GetCwd()
|
||||||
{
|
{
|
||||||
#ifdef _XBOX
|
|
||||||
return SYS_BASE_PATH;
|
|
||||||
#else
|
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
bool ret = getcwd(buf, PATH_MAX) != NULL;
|
bool ret = getcwd(buf, PATH_MAX) != NULL;
|
||||||
ASSERT(ret);
|
ASSERT(ret);
|
||||||
return buf;
|
return buf;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -94,35 +94,6 @@ static const char *EditStateNames[] = {
|
|||||||
XToString( EditState );
|
XToString( EditState );
|
||||||
LuaXType( EditState );
|
LuaXType( EditState );
|
||||||
|
|
||||||
#if defined(XBOX)
|
|
||||||
void ScreenEdit::InitEditMappings()
|
|
||||||
{
|
|
||||||
/* XXX: fill this in */
|
|
||||||
m_EditMappingsDeviceInput.Clear();
|
|
||||||
|
|
||||||
switch( EDIT_MODE.GetValue() )
|
|
||||||
{
|
|
||||||
case EditMode_Practice:
|
|
||||||
m_EditMappingsDeviceInput.button[EDIT_BUTTON_SCROLL_PREV_MEASURE][0] = DeviceInput(DEVICE_JOY1, JOY_HAT_UP);
|
|
||||||
m_EditMappingsMenuButton.button[EDIT_BUTTON_SCROLL_PREV_MEASURE][0] = GAME_BUTTON_UP;
|
|
||||||
m_EditMappingsDeviceInput.button[EDIT_BUTTON_SCROLL_NEXT_MEASURE][0] = DeviceInput(DEVICE_JOY1, JOY_HAT_DOWN);
|
|
||||||
m_EditMappingsMenuButton.button[EDIT_BUTTON_SCROLL_NEXT_MEASURE][0] = GAME_BUTTON_DOWN;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
m_EditMappingsDeviceInput.button[EDIT_BUTTON_SCROLL_UP_LINE][0] = DeviceInput(DEVICE_JOY1, JOY_HAT_UP);
|
|
||||||
m_EditMappingsMenuButton.button[EDIT_BUTTON_SCROLL_UP_LINE][0] = GAME_BUTTON_UP;
|
|
||||||
m_EditMappingsDeviceInput.button[EDIT_BUTTON_SCROLL_DOWN_LINE][0] = DeviceInput(DEVICE_JOY1, JOY_HAT_DOWN);
|
|
||||||
m_EditMappingsMenuButton.button[EDIT_BUTTON_SCROLL_DOWN_LINE][0] = GAME_BUTTON_DOWN;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Map these to the triggers: L goes up, R goes down.
|
|
||||||
m_EditMappingsDeviceInput.button[EDIT_BUTTON_SCROLL_UP_PAGE][0] = DeviceInput(DEVICE_JOY1, JOY_BUTTON_7);
|
|
||||||
//m_EditMappingsMenuButton.button[EDIT_BUTTON_SCROLL_UP_PAGE][0] = GAME_BUTTON_UPLEFT;
|
|
||||||
m_EditMappingsDeviceInput.button[EDIT_BUTTON_SCROLL_DOWN_PAGE][0] = DeviceInput(DEVICE_JOY1, JOY_BUTTON_8);
|
|
||||||
//m_EditMappingsMenuButton.button[EDIT_BUTTON_SCROLL_DOWN_PAGE][0] = GAME_BUTTON_UPRIGHT;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
void ScreenEdit::InitEditMappings()
|
void ScreenEdit::InitEditMappings()
|
||||||
{
|
{
|
||||||
m_EditMappingsDeviceInput.Clear();
|
m_EditMappingsDeviceInput.Clear();
|
||||||
@@ -346,8 +317,6 @@ void ScreenEdit::InitEditMappings()
|
|||||||
m_RecordPausedMappingsDeviceInput.button[EDIT_BUTTON_UNDO][0] = DeviceInput(DEVICE_KEYBOARD, KEY_Cu);
|
m_RecordPausedMappingsDeviceInput.button[EDIT_BUTTON_UNDO][0] = DeviceInput(DEVICE_KEYBOARD, KEY_Cu);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Given a DeviceInput that was just depressed, return an active edit function. */
|
/* Given a DeviceInput that was just depressed, return an active edit function. */
|
||||||
EditButton ScreenEdit::DeviceToEdit( const DeviceInput &DeviceI ) const
|
EditButton ScreenEdit::DeviceToEdit( const DeviceInput &DeviceI ) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -240,28 +240,6 @@ void ScreenMapControllers::Input( const InputEventPlus &input )
|
|||||||
|
|
||||||
int button = input.DeviceI.button;
|
int button = input.DeviceI.button;
|
||||||
|
|
||||||
#ifdef _XBOX
|
|
||||||
if( m_WaitingForPress.IsZero() && input.DeviceI.device == DEVICE_JOY1 )
|
|
||||||
{
|
|
||||||
// map the xbox controller buttons to the keyboard equivalents
|
|
||||||
if( input.DeviceI.button == JOY_HAT_LEFT )
|
|
||||||
button = KEY_LEFT;
|
|
||||||
else if( input.DeviceI.button == JOY_HAT_RIGHT )
|
|
||||||
button = KEY_RIGHT;
|
|
||||||
else if( input.DeviceI.button == JOY_HAT_UP )
|
|
||||||
button = KEY_UP;
|
|
||||||
else if( input.DeviceI.button == JOY_HAT_DOWN )
|
|
||||||
button = KEY_DOWN;
|
|
||||||
else if( input.DeviceI.button == JOY_AUX_1 )
|
|
||||||
button = KEY_ENTER;
|
|
||||||
else if( input.DeviceI.button == JOY_AUX_2 )
|
|
||||||
button = KEY_ESC;
|
|
||||||
else if( input.DeviceI.button == JOY_BUTTON_1 || input.DeviceI.button == JOY_BUTTON_2 ||
|
|
||||||
input.DeviceI.button == JOY_BUTTON_3 || input.DeviceI.button == JOY_BUTTON_4 )
|
|
||||||
button = KEY_DEL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* TRICKY: Some adapters map the PlayStation digital d-pad to both axes and
|
/* TRICKY: Some adapters map the PlayStation digital d-pad to both axes and
|
||||||
* buttons. We want buttons to be used for any mappings where possible
|
* buttons. We want buttons to be used for any mappings where possible
|
||||||
* because presses of buttons aren't mutually exclusive and presses of axes
|
* because presses of buttons aren't mutually exclusive and presses of axes
|
||||||
@@ -293,11 +271,7 @@ void ScreenMapControllers::Input( const InputEventPlus &input )
|
|||||||
m_DeviceIToMap = input.DeviceI;
|
m_DeviceIToMap = input.DeviceI;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef _XBOX
|
|
||||||
else if( input.DeviceI.device == DEVICE_JOY1 )
|
|
||||||
#else
|
|
||||||
else if( input.DeviceI.device == DEVICE_KEYBOARD )
|
else if( input.DeviceI.device == DEVICE_KEYBOARD )
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
switch( button )
|
switch( button )
|
||||||
{
|
{
|
||||||
@@ -310,10 +284,8 @@ void ScreenMapControllers::Input( const InputEventPlus &input )
|
|||||||
* pressed up on the joypad. */
|
* pressed up on the joypad. */
|
||||||
|
|
||||||
case KEY_DEL:
|
case KEY_DEL:
|
||||||
#ifndef _XBOX
|
|
||||||
case KEY_SPACE:
|
case KEY_SPACE:
|
||||||
case KEY_BACK: // Clear the selected input mapping.
|
case KEY_BACK: // Clear the selected input mapping.
|
||||||
#endif
|
|
||||||
if( m_iCurButton == (int) m_KeysToMap.size() )
|
if( m_iCurButton == (int) m_KeysToMap.size() )
|
||||||
break; // on exit
|
break; // on exit
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,6 @@
|
|||||||
#ifndef ScreenServiceAction_H
|
#ifndef ScreenServiceAction_H
|
||||||
#define ScreenServiceAction_H
|
#define ScreenServiceAction_H
|
||||||
|
|
||||||
//There's a FAILED macro somewhere in winerror.h, which gets included with Xbox.
|
|
||||||
#if defined(_XBOX)
|
|
||||||
#undef FAILED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "ScreenPrompt.h"
|
#include "ScreenPrompt.h"
|
||||||
|
|
||||||
class ScreenServiceAction : public ScreenPrompt
|
class ScreenServiceAction : public ScreenPrompt
|
||||||
|
|||||||
@@ -3,10 +3,6 @@
|
|||||||
#ifndef SCREEN_TEST_FONTS_H
|
#ifndef SCREEN_TEST_FONTS_H
|
||||||
#define SCREEN_TEST_FONTS_H
|
#define SCREEN_TEST_FONTS_H
|
||||||
|
|
||||||
#if defined(_XBOX)
|
|
||||||
#undef TEXT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "Screen.h"
|
#include "Screen.h"
|
||||||
#include "BitmapText.h"
|
#include "BitmapText.h"
|
||||||
#include "Quad.h"
|
#include "Quad.h"
|
||||||
|
|||||||
@@ -50,12 +50,7 @@ RString SongCacheIndex::GetCacheFilePath( const RString &sGroup, const RString &
|
|||||||
for( size_t pos = s.find_first_of(invalid); pos != RString::npos; pos = s.find_first_of(invalid, pos) )
|
for( size_t pos = s.find_first_of(invalid); pos != RString::npos; pos = s.find_first_of(invalid, pos) )
|
||||||
s[pos] = '_';
|
s[pos] = '_';
|
||||||
// CACHE_DIR ends with a /.
|
// CACHE_DIR ends with a /.
|
||||||
#if defined(XBOX)
|
|
||||||
// Use CRC32 to make fatx compatible filenames.
|
|
||||||
return ssprintf( "%s%s/%X", SpecialFiles::CACHE_DIR.c_str(), sGroup.c_str(), GetHashForString(s));
|
|
||||||
#else
|
|
||||||
return ssprintf( "%s%s/%s", SpecialFiles::CACHE_DIR.c_str(), sGroup.c_str(), s.c_str() );
|
return ssprintf( "%s%s/%s", SpecialFiles::CACHE_DIR.c_str(), sGroup.c_str(), s.c_str() );
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SongCacheIndex::SongCacheIndex()
|
SongCacheIndex::SongCacheIndex()
|
||||||
|
|||||||
+1
-33
@@ -68,27 +68,12 @@
|
|||||||
#include "SpecialFiles.h"
|
#include "SpecialFiles.h"
|
||||||
#include "Profile.h"
|
#include "Profile.h"
|
||||||
|
|
||||||
#if defined(XBOX)
|
#if defined(WIN32)
|
||||||
#include "Archutils/Xbox/VirtualMemory.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(WIN32) && !defined(XBOX)
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// since the XBOX SDK only works with VS.Net 2003, this doesn't exist yet.
|
|
||||||
// see http://old.nabble.com/Linking-Error-with-MSVC%2B%2B-6.0-td21608559.html
|
|
||||||
// for more information. -aj
|
|
||||||
#if defined(XBOX)
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
int _get_output_format( void ){ return 0; }
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static Preference<bool> g_bAllowMultipleInstances( "AllowMultipleInstances", false );
|
static Preference<bool> g_bAllowMultipleInstances( "AllowMultipleInstances", false );
|
||||||
|
|
||||||
|
|
||||||
void StepMania::GetPreferredVideoModeParams( VideoModeParams ¶msOut )
|
void StepMania::GetPreferredVideoModeParams( VideoModeParams ¶msOut )
|
||||||
{
|
{
|
||||||
/* We can't rely on there being full-screen video modes that give us square
|
/* We can't rely on there being full-screen video modes that give us square
|
||||||
@@ -469,14 +454,6 @@ struct VideoCardDefaults
|
|||||||
}
|
}
|
||||||
} const g_VideoCardDefaults[] =
|
} const g_VideoCardDefaults[] =
|
||||||
{
|
{
|
||||||
VideoCardDefaults(
|
|
||||||
"Xbox",
|
|
||||||
"d3d",
|
|
||||||
600,400,
|
|
||||||
32,32,32,
|
|
||||||
2048,
|
|
||||||
true
|
|
||||||
),
|
|
||||||
VideoCardDefaults(
|
VideoCardDefaults(
|
||||||
"Voodoo *5",
|
"Voodoo *5",
|
||||||
"d3d,opengl", // received 3 reports of opengl crashing. -Chris
|
"d3d,opengl", // received 3 reports of opengl crashing. -Chris
|
||||||
@@ -636,8 +613,6 @@ static RString GetVideoDriverName()
|
|||||||
{
|
{
|
||||||
#if defined(_WINDOWS)
|
#if defined(_WINDOWS)
|
||||||
return GetPrimaryVideoDriverName();
|
return GetPrimaryVideoDriverName();
|
||||||
#elif defined(_XBOX)
|
|
||||||
return "Xbox";
|
|
||||||
#else
|
#else
|
||||||
return "OpenGL";
|
return "OpenGL";
|
||||||
#endif
|
#endif
|
||||||
@@ -879,11 +854,8 @@ static void MountTreeOfZips( const RString &dir )
|
|||||||
RString path = dirs.back();
|
RString path = dirs.back();
|
||||||
dirs.pop_back();
|
dirs.pop_back();
|
||||||
|
|
||||||
#if !defined(XBOX)
|
|
||||||
// Xbox doesn't detect directories properly, so we'll ignore this
|
|
||||||
if( !IsADirectory(path) )
|
if( !IsADirectory(path) )
|
||||||
continue;
|
continue;
|
||||||
#endif
|
|
||||||
|
|
||||||
vector<RString> zips;
|
vector<RString> zips;
|
||||||
GetDirListing( path + "/*.zip", zips, false, true );
|
GetDirListing( path + "/*.zip", zips, false, true );
|
||||||
@@ -997,10 +969,6 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
ApplyLogPreferences();
|
ApplyLogPreferences();
|
||||||
|
|
||||||
#if defined(XBOX)
|
|
||||||
vmem_Manager.Init();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
WriteLogHeader();
|
WriteLogHeader();
|
||||||
|
|
||||||
// Set up alternative filesystem trees.
|
// Set up alternative filesystem trees.
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -100,22 +100,10 @@ void GetBounds( const Surface *pSurf, RECT *out )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#pragma include_alias( "zlib/zlib.h", "../zlib/zlib.h" )
|
#pragma include_alias( "zlib/zlib.h", "../zlib/zlib.h" )
|
||||||
#include "../libpng/include/png.h"
|
#include "../libpng/include/png.h"
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
# if defined(_XBOX)
|
# pragma comment(lib, "../libpng/lib/libpng.lib")
|
||||||
# pragma comment(lib, "../libpng/lib/xboxlibpng.lib")
|
|
||||||
# else
|
|
||||||
# pragma comment(lib, "../libpng/lib/libpng.lib")
|
|
||||||
# endif
|
|
||||||
#pragma warning(disable: 4611) /* interaction between '_setjmp' and C++ object destruction is non-portable */
|
#pragma warning(disable: 4611) /* interaction between '_setjmp' and C++ object destruction is non-portable */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1,227 +0,0 @@
|
|||||||
#include "global.h"
|
|
||||||
#include "ArchHooks_Xbox.h"
|
|
||||||
#include "dsound.h" // for timeGetTime
|
|
||||||
#include "archutils/Xbox/custom_launch_params.h" // for XGetCustomLaunchData
|
|
||||||
#include "archutils/Xbox/VirtualMemory.h"
|
|
||||||
|
|
||||||
#include <xtl.h> // for XNetStartup
|
|
||||||
#include <new.h> // for _set_new_handler and _set_new_mode
|
|
||||||
|
|
||||||
typedef struct _UNICODE_STRING {unsigned short Length; unsigned short MaximumLength; PSTR Buffer;} UNICODE_STRING,*PUNICODE_STRING;
|
|
||||||
extern "C" XBOXAPI DWORD WINAPI IoCreateSymbolicLink(IN PUNICODE_STRING SymbolicLinkName,IN PUNICODE_STRING DeviceName);
|
|
||||||
|
|
||||||
static bool g_bTimerInitialized;
|
|
||||||
static DWORD g_iStartTime;
|
|
||||||
|
|
||||||
static void InitTimer()
|
|
||||||
{
|
|
||||||
if( g_bTimerInitialized )
|
|
||||||
return;
|
|
||||||
g_bTimerInitialized = true;
|
|
||||||
|
|
||||||
g_iStartTime = timeGetTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t ArchHooks::GetMicrosecondsSinceStart( bool bAccurate )
|
|
||||||
{
|
|
||||||
if( !g_bTimerInitialized )
|
|
||||||
InitTimer();
|
|
||||||
|
|
||||||
int64_t ret = (timeGetTime() - g_iStartTime) * int64_t(1000);
|
|
||||||
if( bAccurate )
|
|
||||||
{
|
|
||||||
ret = FixupTimeIfLooped( ret );
|
|
||||||
ret = FixupTimeIfBackwards( ret );
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MountDriveLetter(char drive, char* szDevice, char* szDir)
|
|
||||||
{
|
|
||||||
char szSourceDevice[256];
|
|
||||||
char szDestinationDrive[16];
|
|
||||||
sprintf(szDestinationDrive, "\\??\\%c:", drive);
|
|
||||||
sprintf(szSourceDevice,"\\Device\\%s",szDevice);
|
|
||||||
if (*szDir != 0x00 && *szDir != '\\')
|
|
||||||
{
|
|
||||||
strcat(szSourceDevice, "\\");
|
|
||||||
strcat(szSourceDevice, szDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
UNICODE_STRING LinkName =
|
|
||||||
{
|
|
||||||
strlen(szDestinationDrive),
|
|
||||||
strlen(szDestinationDrive) + 1,
|
|
||||||
szDestinationDrive
|
|
||||||
};
|
|
||||||
UNICODE_STRING DeviceName =
|
|
||||||
{
|
|
||||||
strlen(szSourceDevice),
|
|
||||||
strlen(szSourceDevice) + 1,
|
|
||||||
szSourceDevice
|
|
||||||
};
|
|
||||||
|
|
||||||
IoCreateSymbolicLink(&LinkName, &DeviceName);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MountDrives()
|
|
||||||
{
|
|
||||||
MountDriveLetter('A', "Cdrom0", "\\");
|
|
||||||
MountDriveLetter('E', "Harddisk0\\Partition1", "\\");
|
|
||||||
MountDriveLetter('C', "Harddisk0\\Partition2", "\\");
|
|
||||||
MountDriveLetter('X', "Harddisk0\\Partition3", "\\");
|
|
||||||
MountDriveLetter('Y', "Harddisk0\\Partition4", "\\");
|
|
||||||
MountDriveLetter('F', "Harddisk0\\Partition6", "\\");
|
|
||||||
MountDriveLetter('G', "Harddisk0\\Partition7", "\\");
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SetupNetwork()
|
|
||||||
{
|
|
||||||
#if !defined(WITHOUT_NETWORKING)
|
|
||||||
XNetStartupParams xnsp;
|
|
||||||
memset(&xnsp, 0, sizeof(xnsp));
|
|
||||||
xnsp.cfgSizeOfStruct = sizeof(XNetStartupParams);
|
|
||||||
xnsp.cfgFlags = XNET_STARTUP_BYPASS_SECURITY;
|
|
||||||
|
|
||||||
INT err = XNetStartup(&xnsp);
|
|
||||||
|
|
||||||
return err == 0;
|
|
||||||
#else
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// if Xbox has 128 meg RAM make sure its used
|
|
||||||
void EnableExtraRAM()
|
|
||||||
{
|
|
||||||
LARGE_INTEGER regVal;
|
|
||||||
|
|
||||||
// Verify that we have 128 megs available
|
|
||||||
MEMORYSTATUS memStatus;
|
|
||||||
GlobalMemoryStatus( &memStatus );
|
|
||||||
if( memStatus.dwTotalPhys < (100 * 1024 * 1024) )
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Grab the existing default type (0x02FF)
|
|
||||||
READMSRREG( 0x02FF, ®Val );
|
|
||||||
|
|
||||||
// Set the default to WriteBack (0x06)
|
|
||||||
regVal.LowPart = (regVal.LowPart & ~0xFF) | 0x06;
|
|
||||||
WRITEMSRREG( 0x02FF, regVal );
|
|
||||||
}
|
|
||||||
|
|
||||||
void InitDevices()
|
|
||||||
{
|
|
||||||
XDEVICE_PREALLOC_TYPE xdpt[] = {{XDEVICE_TYPE_GAMEPAD, 4}, {XDEVICE_TYPE_MEMORY_UNIT, 2}};
|
|
||||||
XInitDevices( sizeof(xdpt) / sizeof(XDEVICE_PREALLOC_TYPE), xdpt );
|
|
||||||
}
|
|
||||||
|
|
||||||
ArchHooks_Xbox::ArchHooks_Xbox()
|
|
||||||
{
|
|
||||||
_set_new_handler(NoMemory);
|
|
||||||
_set_new_mode(1);
|
|
||||||
SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER) CheckPageFault);
|
|
||||||
|
|
||||||
XGetCustomLaunchData();
|
|
||||||
|
|
||||||
// mount A to DVD, C, E, F, G, X, and Y to the harddisk
|
|
||||||
MountDrives();
|
|
||||||
|
|
||||||
SetupNetwork();
|
|
||||||
|
|
||||||
EnableExtraRAM();
|
|
||||||
|
|
||||||
InitDevices();
|
|
||||||
}
|
|
||||||
|
|
||||||
static RString XLangID( DWORD Lang )
|
|
||||||
{
|
|
||||||
switch(Lang)
|
|
||||||
{
|
|
||||||
case XC_LANGUAGE_JAPANESE:return "JA";
|
|
||||||
case XC_LANGUAGE_GERMAN:return "DE";
|
|
||||||
case XC_LANGUAGE_FRENCH:return "FR";
|
|
||||||
case XC_LANGUAGE_SPANISH:return "ES";
|
|
||||||
case XC_LANGUAGE_ITALIAN:return "IT";
|
|
||||||
case XC_LANGUAGE_KOREAN:return "KO";
|
|
||||||
case XC_LANGUAGE_TCHINESE:return "ZH";
|
|
||||||
case XC_LANGUAGE_PORTUGUESE:return "PT";
|
|
||||||
default:
|
|
||||||
case XC_LANGUAGE_ENGLISH: return "EN";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RString ArchHooks::GetPreferredLanguage()
|
|
||||||
{
|
|
||||||
return XLangID( XGetLanguage() );
|
|
||||||
}
|
|
||||||
|
|
||||||
ArchHooks_Xbox::~ArchHooks_Xbox()
|
|
||||||
{
|
|
||||||
// We only want to reboot the Xbox in a software manner.
|
|
||||||
XLaunchNewImage( NULL, NULL );
|
|
||||||
}
|
|
||||||
|
|
||||||
void ArchHooks_Xbox::DumpDebugInfo()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
float ArchHooks_Xbox::GetDisplayAspectRatio()
|
|
||||||
{
|
|
||||||
// xxx: does this take into account system settings? -aj
|
|
||||||
float fDisplayAspectRatio = 4.0 / 3.0;
|
|
||||||
IDirect3DSurface8 *pBackBuffer = NULL;
|
|
||||||
if( D3D__pDevice->GetBackBuffer( -1, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer) == D3D_OK )
|
|
||||||
{
|
|
||||||
D3DSURFACE_DESC Desc;
|
|
||||||
if( pBackBuffer->GetDesc(&Desc) == D3D_OK )
|
|
||||||
{
|
|
||||||
fDisplayAspectRatio = (float)Desc.Width / (float)Desc.Height;
|
|
||||||
}
|
|
||||||
pBackBuffer->Release();
|
|
||||||
}
|
|
||||||
return fDisplayAspectRatio;
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "RageFileManager.h"
|
|
||||||
|
|
||||||
void ArchHooks::MountInitialFilesystems( const RString &sDirOfExecutable )
|
|
||||||
{
|
|
||||||
FILEMAN->Mount( "dir", "D:\\", "/" );
|
|
||||||
}
|
|
||||||
|
|
||||||
void ArchHooks::MountUserFilesystems( const RString &sDirOfExecutable )
|
|
||||||
{
|
|
||||||
// Mount everything game-writable (not counting the editor) to the game title persistent data region ( /E/TDATA/33342530/ )
|
|
||||||
FILEMAN->Mount( "dir", "T:/Cache", "/Cache" );
|
|
||||||
FILEMAN->Mount( "dir", "T:/Logs", "/Logs" );
|
|
||||||
FILEMAN->Mount( "dir", "T:/Save", "/Save" );
|
|
||||||
FILEMAN->Mount( "dir", "T:/Screenshots", "/Screenshots" );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (c) 2003-2004 Glenn Maynard, Chris Danford
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
||||||
* whom the Software is furnished to do so, provided that the above
|
|
||||||
* copyright notice(s) and this permission notice appear in all copies of
|
|
||||||
* the Software and that both the above copyright notice(s) and this
|
|
||||||
* permission notice appear in supporting documentation.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
||||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
||||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
||||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
||||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
||||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
||||||
* PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
#ifndef ARCH_HOOKS_XBOX_H
|
|
||||||
#define ARCH_HOOKS_XBOX_H
|
|
||||||
|
|
||||||
#include "ArchHooks.h"
|
|
||||||
class RageMutex;
|
|
||||||
|
|
||||||
class ArchHooks_Xbox: public ArchHooks
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ArchHooks_Xbox();
|
|
||||||
~ArchHooks_Xbox();
|
|
||||||
RString GetArchName() { return "Xbox"; }
|
|
||||||
void DumpDebugInfo();
|
|
||||||
float GetDisplayAspectRatio();
|
|
||||||
|
|
||||||
//void MountInitialFilesystems( const RString &sDirOfExecutable );
|
|
||||||
};
|
|
||||||
|
|
||||||
// XXX: This stuff doesn't belong here. Hide it in ArchHooks.
|
|
||||||
|
|
||||||
// Read a 64 bit MSR register
|
|
||||||
inline void READMSRREG( UINT32 reg, LARGE_INTEGER *val )
|
|
||||||
{
|
|
||||||
UINT32 lowPart, highPart;
|
|
||||||
__asm
|
|
||||||
{
|
|
||||||
mov ecx, reg
|
|
||||||
rdmsr
|
|
||||||
mov lowPart, eax
|
|
||||||
mov highPart, edx
|
|
||||||
};
|
|
||||||
|
|
||||||
val->LowPart = lowPart;
|
|
||||||
val->HighPart = highPart;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write a 64 bit MSR register
|
|
||||||
inline void WRITEMSRREG( UINT32 reg, LARGE_INTEGER val )
|
|
||||||
{
|
|
||||||
__asm
|
|
||||||
{
|
|
||||||
mov ecx, reg
|
|
||||||
mov eax, val.LowPart
|
|
||||||
mov edx, val.HighPart
|
|
||||||
wrmsr
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef ARCH_HOOKS
|
|
||||||
#error "More than one ArchHooks selected!"
|
|
||||||
#endif
|
|
||||||
#define ARCH_HOOKS ArchHooks_Xbox
|
|
||||||
|
|
||||||
#endif
|
|
||||||
/*
|
|
||||||
* (c) 2002-2004 Glenn Maynard, Chris Danford
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
||||||
* whom the Software is furnished to do so, provided that the above
|
|
||||||
* copyright notice(s) and this permission notice appear in all copies of
|
|
||||||
* the Software and that both the above copyright notice(s) and this
|
|
||||||
* permission notice appear in supporting documentation.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
||||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
||||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
||||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
||||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
||||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
||||||
* PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
@@ -1,232 +0,0 @@
|
|||||||
#include "global.h"
|
|
||||||
#include "InputHandler_Xbox.h"
|
|
||||||
#include "RageUtil.h"
|
|
||||||
#include "RageLog.h"
|
|
||||||
#include "RageDisplay.h"
|
|
||||||
|
|
||||||
|
|
||||||
#include <xtl.h>
|
|
||||||
|
|
||||||
struct DEVICE_STATE {
|
|
||||||
XPP_DEVICE_TYPE *pxdt;
|
|
||||||
DWORD dwState;
|
|
||||||
};
|
|
||||||
|
|
||||||
byte buttonMasks[] = { XINPUT_GAMEPAD_DPAD_LEFT,
|
|
||||||
XINPUT_GAMEPAD_DPAD_RIGHT,
|
|
||||||
XINPUT_GAMEPAD_DPAD_UP,
|
|
||||||
XINPUT_GAMEPAD_DPAD_DOWN,
|
|
||||||
XINPUT_GAMEPAD_START,
|
|
||||||
XINPUT_GAMEPAD_BACK,
|
|
||||||
XINPUT_GAMEPAD_LEFT_THUMB,
|
|
||||||
XINPUT_GAMEPAD_RIGHT_THUMB};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* XBOX controller maps to the following RageInputDevice constants:
|
|
||||||
* DPAD -> JOY_HAT_...
|
|
||||||
* START -> JOY_AUX_1
|
|
||||||
* BACK -> JOY_AUX_2
|
|
||||||
* Left thumb button -> JOY_AUX_3
|
|
||||||
* Right thumb button -> JOY_AUX_4
|
|
||||||
* Following buttons are JOY_(index):
|
|
||||||
* A, B, X, Y, BLACK, WHITE, Left trigger, right trigger
|
|
||||||
*/
|
|
||||||
|
|
||||||
InputHandler_Xbox::InputHandler_Xbox()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Init joysticks
|
|
||||||
//
|
|
||||||
ZeroMemory( joysticks, sizeof(joysticks) );
|
|
||||||
|
|
||||||
getHandles();
|
|
||||||
}
|
|
||||||
|
|
||||||
InputHandler_Xbox::~InputHandler_Xbox()
|
|
||||||
{
|
|
||||||
for(unsigned i = 0; i < NUM_JOYSTICKS; i++)
|
|
||||||
{
|
|
||||||
if(joysticks[i] != 0)
|
|
||||||
XInputClose(joysticks[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputHandler_Xbox::Update()
|
|
||||||
{
|
|
||||||
// check insertions and removals
|
|
||||||
DWORD dwInsert, dwRemove;
|
|
||||||
DEVICE_STATE devices = {XDEVICE_TYPE_GAMEPAD, 0};
|
|
||||||
|
|
||||||
bool changes = false;
|
|
||||||
// Check each device type to see if any changes have occurred.
|
|
||||||
if( XGetDeviceChanges( devices.pxdt, &dwInsert, &dwRemove ) )
|
|
||||||
{
|
|
||||||
for(int j = 0; j < 4; j++)
|
|
||||||
{
|
|
||||||
if(1 << j & dwRemove)
|
|
||||||
{
|
|
||||||
changes = true;
|
|
||||||
LOG->Trace("A joystick was removed");
|
|
||||||
}
|
|
||||||
if(1 << j & dwInsert)
|
|
||||||
{
|
|
||||||
changes = true;
|
|
||||||
LOG->Trace("A joystick was inserted");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(changes)
|
|
||||||
{
|
|
||||||
getHandles();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(unsigned i = 0; i < NUM_JOYSTICKS; i++)
|
|
||||||
{
|
|
||||||
if(joysticks[i] == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
InputDevice inputDevice = InputDevice(DEVICE_JOY1 + i);
|
|
||||||
XINPUT_STATE xis;
|
|
||||||
// Query latest state.
|
|
||||||
XInputGetState( joysticks[i], &xis );
|
|
||||||
|
|
||||||
// check buttons
|
|
||||||
for(int j = 0; j < ARRAYLEN(buttonMasks); j++)
|
|
||||||
{
|
|
||||||
DWORD nowPressed = xis.Gamepad.wButtons & buttonMasks[j];
|
|
||||||
DWORD wasPressed = lastState[i].wButtons & buttonMasks[j];
|
|
||||||
|
|
||||||
if(nowPressed != wasPressed)
|
|
||||||
{
|
|
||||||
DeviceButton Button = DeviceButton(JOY_HAT_LEFT + j);
|
|
||||||
if(Button >= JOY_BUTTON_32)
|
|
||||||
{
|
|
||||||
LOG->Warn("Ignored joystick event (button too high)");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
DeviceInput di(inputDevice, Button, nowPressed != 0);
|
|
||||||
ButtonPressed(di);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// check analog buttons
|
|
||||||
for(int j = 0; j < ARRAYLEN(xis.Gamepad.bAnalogButtons); j++)
|
|
||||||
{
|
|
||||||
bool nowPressed = xis.Gamepad.bAnalogButtons[j] > XINPUT_GAMEPAD_MAX_CROSSTALK;
|
|
||||||
bool wasPressed = lastState[i].bAnalogButtons[j] > XINPUT_GAMEPAD_MAX_CROSSTALK;
|
|
||||||
|
|
||||||
if(nowPressed != wasPressed)
|
|
||||||
{
|
|
||||||
DeviceButton Button = DeviceButton(JOY_BUTTON_1 + j);
|
|
||||||
if(Button >= JOY_BUTTON_32)
|
|
||||||
{
|
|
||||||
LOG->Warn("Ignored joystick event (button too high)");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
DeviceInput di(inputDevice, Button, nowPressed);
|
|
||||||
ButtonPressed(di);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// check thumbsticks
|
|
||||||
SHORT axes[] = { xis.Gamepad.sThumbLX, xis.Gamepad.sThumbLY, xis.Gamepad.sThumbRX, xis.Gamepad.sThumbRY};
|
|
||||||
|
|
||||||
for(int j = 0; j < ARRAYLEN(axes); j++)
|
|
||||||
{
|
|
||||||
if(axes[j] != 0)
|
|
||||||
{
|
|
||||||
// Reverse y axis (negative values are down, not up)
|
|
||||||
if(j == 1 || j == 3)
|
|
||||||
axes[j] = -axes[j];
|
|
||||||
|
|
||||||
DeviceButton neg = (DeviceButton)(JOY_LEFT + (2 * j));
|
|
||||||
DeviceButton pos = (DeviceButton)(JOY_RIGHT + (2 * j));
|
|
||||||
float l = SCALE( axes[j], 0.0f, 32768.0f, 0.0f, 1.0f );
|
|
||||||
ButtonPressed(DeviceInput(inputDevice, neg,max(-l,0),RageZeroTimer));
|
|
||||||
ButtonPressed(DeviceInput(inputDevice, pos,max(+l,0),RageZeroTimer));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(&lastState[i], &xis.Gamepad, sizeof(XINPUT_GAMEPAD));
|
|
||||||
}
|
|
||||||
|
|
||||||
InputHandler::UpdateTimer();
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputHandler_Xbox::GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevicesOut )
|
|
||||||
{
|
|
||||||
for( int i=0; i<NUM_JOYSTICKS; i++ )
|
|
||||||
{
|
|
||||||
if( joysticks[i] != 0 )
|
|
||||||
{
|
|
||||||
vDevicesOut.push_back( InputDeviceInfo(InputDevice(DEVICE_JOY1+i),"XboxGameHardware") );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputHandler_Xbox::getHandles()
|
|
||||||
{
|
|
||||||
for(unsigned i = 0; i < NUM_JOYSTICKS; i++)
|
|
||||||
{
|
|
||||||
if(joysticks[i] != 0)
|
|
||||||
XInputClose(joysticks[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
ZeroMemory( joysticks, sizeof(joysticks) );
|
|
||||||
ZeroMemory( lastState, sizeof(lastState) );
|
|
||||||
|
|
||||||
// Work out joystick handles
|
|
||||||
DEVICE_STATE devices = {XDEVICE_TYPE_GAMEPAD, 0};
|
|
||||||
devices.dwState = XGetDevices( devices.pxdt );
|
|
||||||
|
|
||||||
// Check the global gamepad state for a connected device.
|
|
||||||
unsigned playersAllocated = 0;
|
|
||||||
unsigned joysFound = 0;
|
|
||||||
|
|
||||||
for( unsigned i = 0; i < NUM_PORTS; i++ )
|
|
||||||
{
|
|
||||||
if( devices.dwState & 1 << i)
|
|
||||||
{
|
|
||||||
if(playersAllocated < NUM_JOYSTICKS)
|
|
||||||
{
|
|
||||||
XINPUT_POLLING_PARAMETERS pollingParameters = {TRUE, TRUE, 0, 8, 8, 0,};
|
|
||||||
joysticks[playersAllocated] = XInputOpen(XDEVICE_TYPE_GAMEPAD, (DWORD)i, XDEVICE_NO_SLOT, &pollingParameters);
|
|
||||||
playersAllocated++;
|
|
||||||
}
|
|
||||||
joysFound++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG->Info( "Found %d connected joysticks for %d players", joysFound, playersAllocated );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (c) 2004 Ryan Dortmans
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
||||||
* whom the Software is furnished to do so, provided that the above
|
|
||||||
* copyright notice(s) and this permission notice appear in all copies of
|
|
||||||
* the Software and that both the above copyright notice(s) and this
|
|
||||||
* permission notice appear in supporting documentation.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
||||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
||||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
||||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
||||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
||||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
||||||
* PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
#ifndef INPUT_HANDLER_XBOX_H
|
|
||||||
#define INPUT_HANDLER_XBOX_H
|
|
||||||
|
|
||||||
#include "InputHandler.h"
|
|
||||||
|
|
||||||
#include <xtl.h>
|
|
||||||
|
|
||||||
#define NUM_PORTS 4
|
|
||||||
|
|
||||||
class InputHandler_Xbox: public InputHandler
|
|
||||||
{
|
|
||||||
HANDLE joysticks[NUM_JOYSTICKS];
|
|
||||||
XINPUT_GAMEPAD lastState[NUM_JOYSTICKS];
|
|
||||||
|
|
||||||
public:
|
|
||||||
void Update();
|
|
||||||
InputHandler_Xbox();
|
|
||||||
~InputHandler_Xbox();
|
|
||||||
void GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevicesOut );
|
|
||||||
|
|
||||||
private:
|
|
||||||
void getHandles();
|
|
||||||
};
|
|
||||||
#define USE_INPUT_HANDLER_XBOX
|
|
||||||
REGISTER_INPUT_HANDLER_CLASS( Xbox );
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (c) 2004 Ryan Dortmans
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
||||||
* whom the Software is furnished to do so, provided that the above
|
|
||||||
* copyright notice(s) and this permission notice appear in all copies of
|
|
||||||
* the Software and that both the above copyright notice(s) and this
|
|
||||||
* permission notice appear in supporting documentation.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
||||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
||||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
||||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
||||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
||||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
||||||
* PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
@@ -12,7 +12,7 @@ LoadingWindow *LoadingWindow::Create()
|
|||||||
return new LoadingWindow_Null;
|
return new LoadingWindow_Null;
|
||||||
#endif
|
#endif
|
||||||
// Don't load NULL by default.
|
// Don't load NULL by default.
|
||||||
const RString drivers = "xbox,win32,macosx,gtk";
|
const RString drivers = "win32,macosx,gtk";
|
||||||
vector<RString> DriversToTry;
|
vector<RString> DriversToTry;
|
||||||
split( drivers, ",", DriversToTry, true );
|
split( drivers, ",", DriversToTry, true );
|
||||||
|
|
||||||
@@ -33,9 +33,6 @@ LoadingWindow *LoadingWindow::Create()
|
|||||||
#endif
|
#endif
|
||||||
#ifdef USE_LOADING_WINDOW_WIN32
|
#ifdef USE_LOADING_WINDOW_WIN32
|
||||||
if( !DriversToTry[i].CompareNoCase("Win32") ) ret = new LoadingWindow_Win32;
|
if( !DriversToTry[i].CompareNoCase("Win32") ) ret = new LoadingWindow_Win32;
|
||||||
#endif
|
|
||||||
#ifdef USE_LOADING_WINDOW_XBOX
|
|
||||||
if( !DriversToTry[i].CompareNoCase("Xbox") ) ret = new LoadingWindow_Xbox;
|
|
||||||
#endif
|
#endif
|
||||||
if( !DriversToTry[i].CompareNoCase("Null") ) ret = new LoadingWindow_Null;
|
if( !DriversToTry[i].CompareNoCase("Null") ) ret = new LoadingWindow_Null;
|
||||||
|
|
||||||
|
|||||||
@@ -1,179 +0,0 @@
|
|||||||
#include "global.h"
|
|
||||||
#include "LoadingWindow_Xbox.h"
|
|
||||||
#include "RageLog.h"
|
|
||||||
|
|
||||||
#include "ProductInfo.h"
|
|
||||||
|
|
||||||
LPDIRECT3D8 g_pD3D = NULL; // DirectX Object
|
|
||||||
LPDIRECT3DDEVICE8 g_pD3DDevice = NULL; // Screen Object
|
|
||||||
LPDIRECT3DTEXTURE8 splash = NULL; // splash texture
|
|
||||||
LPD3DXSPRITE g_sprite = NULL; // sprite object
|
|
||||||
|
|
||||||
LoadingWindow_Xbox::LoadingWindow_Xbox()
|
|
||||||
{
|
|
||||||
// Initialise Direct3D
|
|
||||||
g_pD3D = Direct3DCreate8(D3D_SDK_VERSION);
|
|
||||||
|
|
||||||
// Create a structure to hold the settings for our device
|
|
||||||
D3DPRESENT_PARAMETERS d3dpp;
|
|
||||||
ZeroMemory(&d3dpp, sizeof(d3dpp));
|
|
||||||
|
|
||||||
// Fill the structure.
|
|
||||||
// Set fullscreen 640x480x32 mode
|
|
||||||
d3dpp.BackBufferWidth = 640;
|
|
||||||
d3dpp.BackBufferHeight = 480;
|
|
||||||
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
|
|
||||||
|
|
||||||
// Create one backbuffer and a zbuffer
|
|
||||||
d3dpp.BackBufferCount = 1;
|
|
||||||
|
|
||||||
// Set up how the backbuffer is "presented" to the frontbuffer each time
|
|
||||||
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
|
||||||
|
|
||||||
//Create a Direct3D device.
|
|
||||||
g_pD3D->CreateDevice(0, D3DDEVTYPE_HAL, NULL,
|
|
||||||
D3DCREATE_HARDWARE_VERTEXPROCESSING,
|
|
||||||
&d3dpp, &g_pD3DDevice);
|
|
||||||
g_pD3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
|
|
||||||
|
|
||||||
// Create the sprite object (for painting the image)
|
|
||||||
D3DXCreateSprite(g_pD3DDevice, &g_sprite);
|
|
||||||
|
|
||||||
// Load the default font
|
|
||||||
XFONT_OpenDefaultFont(&font);
|
|
||||||
font->SetTextColor(D3DCOLOR_XRGB(255,255,255));
|
|
||||||
font->SetTextAlignment(XFONT_CENTER);
|
|
||||||
|
|
||||||
// Load the splash.png
|
|
||||||
|
|
||||||
HRESULT result = D3DXCreateTextureFromFileA(g_pD3DDevice, "D:\\Data\\splash.png", &splash);
|
|
||||||
useImage = (result == D3D_OK);
|
|
||||||
|
|
||||||
if(!useImage)
|
|
||||||
LOG->Trace("Error loading splash.png - %i", result);
|
|
||||||
|
|
||||||
SetText(RString("Loading songs"));
|
|
||||||
}
|
|
||||||
|
|
||||||
LoadingWindow_Xbox::~LoadingWindow_Xbox()
|
|
||||||
{
|
|
||||||
g_pD3DDevice->Release();
|
|
||||||
g_pD3D->Release();
|
|
||||||
font->Release();
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoadingWindow_Xbox::Paint()
|
|
||||||
{
|
|
||||||
LPDIRECT3DSURFACE8 g_pFrontBuffer;
|
|
||||||
|
|
||||||
if(text == "")
|
|
||||||
return;
|
|
||||||
|
|
||||||
g_pD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
|
|
||||||
|
|
||||||
g_pD3DDevice->BeginScene();
|
|
||||||
g_pD3DDevice->GetBackBuffer(0,D3DBACKBUFFER_TYPE_MONO,&g_pFrontBuffer);
|
|
||||||
|
|
||||||
if(useImage)
|
|
||||||
{
|
|
||||||
// Draw the splash image
|
|
||||||
// Only draw if the splash texture is successfully loaded
|
|
||||||
D3DXVECTOR2 pos;
|
|
||||||
pos.x = 70.0f;
|
|
||||||
pos.y = 30.0f;
|
|
||||||
|
|
||||||
g_sprite->Begin();
|
|
||||||
g_sprite->Draw(splash, NULL, NULL, NULL, NULL, &pos, 0xFFFFFFFF);
|
|
||||||
g_sprite->End();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Lo-fi version: print the product name and version at the top of the screen
|
|
||||||
font->SetTextColor(D3DCOLOR_XRGB(255, 0, 0));
|
|
||||||
RString title = "Version ";
|
|
||||||
title = title + PRODUCT_VER;
|
|
||||||
WCHAR wc_title[200] = {0};
|
|
||||||
swprintf(wc_title, L"%S", title.c_str());
|
|
||||||
|
|
||||||
font->TextOut(g_pFrontBuffer, L"StepMania", -1, 320, 30);
|
|
||||||
font->SetTextColor(D3DCOLOR_XRGB(255, 255, 0));
|
|
||||||
font->TextOut(g_pFrontBuffer, wc_title, -1, 320, 40 + font->GetTextHeight());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw the text on the screen
|
|
||||||
font->SetTextColor(D3DCOLOR_XRGB(255, 255, 255));
|
|
||||||
basic_string <char>::size_type newLineIndex = text.find("\n", 0);
|
|
||||||
int y = 240;
|
|
||||||
|
|
||||||
if(newLineIndex == RString.npos)
|
|
||||||
{
|
|
||||||
WCHAR wc_text[200] = {0};
|
|
||||||
swprintf(wc_text, L"%S", text.c_str());
|
|
||||||
|
|
||||||
font->TextOut(g_pFrontBuffer, wc_text, wcslen(wc_text), 320, y);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int start = 0;
|
|
||||||
|
|
||||||
while(start != RString.npos)
|
|
||||||
{
|
|
||||||
RString toPrint;
|
|
||||||
if(newLineIndex != RString.npos)
|
|
||||||
toPrint = text.substr(start, newLineIndex - start);
|
|
||||||
else
|
|
||||||
toPrint = text.substr(start);
|
|
||||||
|
|
||||||
if(toPrint != "")
|
|
||||||
{
|
|
||||||
WCHAR wc_text[200] = {0};
|
|
||||||
swprintf(wc_text, L"%S", toPrint.c_str());
|
|
||||||
|
|
||||||
font->TextOut(g_pFrontBuffer, wc_text, wcslen(wc_text), 320, y);
|
|
||||||
}
|
|
||||||
y = y + font->GetTextHeight() + 10;
|
|
||||||
|
|
||||||
if(newLineIndex != RString.npos)
|
|
||||||
start = newLineIndex + 1;
|
|
||||||
else
|
|
||||||
start = RString.npos;
|
|
||||||
|
|
||||||
newLineIndex = text.find("\n", start);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
g_pFrontBuffer->Release();
|
|
||||||
|
|
||||||
g_pD3DDevice->EndScene();
|
|
||||||
g_pD3DDevice->Present(NULL, NULL, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoadingWindow_Xbox::SetText(RString str)
|
|
||||||
{
|
|
||||||
text = str ;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (c) 2004 Ryan Dortmans
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
||||||
* whom the Software is furnished to do so, provided that the above
|
|
||||||
* copyright notice(s) and this permission notice appear in all copies of
|
|
||||||
* the Software and that both the above copyright notice(s) and this
|
|
||||||
* permission notice appear in supporting documentation.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
||||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
||||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
||||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
||||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
||||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
||||||
* PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
#ifndef LOADING_WINDOW_XBOX_H
|
|
||||||
#define LOADING_WINDOW_XBOX_H
|
|
||||||
|
|
||||||
#include "LoadingWindow.h"
|
|
||||||
|
|
||||||
#include <xtl.h>
|
|
||||||
#include <xfont.h>
|
|
||||||
#define XFONT_TRUETYPE
|
|
||||||
|
|
||||||
class LoadingWindow_Xbox: public LoadingWindow
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
LoadingWindow_Xbox();
|
|
||||||
~LoadingWindow_Xbox();
|
|
||||||
|
|
||||||
void Paint();
|
|
||||||
void SetText(RString str);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
RString text ;
|
|
||||||
XFONT* font;
|
|
||||||
bool useImage;
|
|
||||||
};
|
|
||||||
#define USE_LOADING_WINDOW_XBOX
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (c) 2004 Ryan Dortmans
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
||||||
* whom the Software is furnished to do so, provided that the above
|
|
||||||
* copyright notice(s) and this permission notice appear in all copies of
|
|
||||||
* the Software and that both the above copyright notice(s) and this
|
|
||||||
* permission notice appear in supporting documentation.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
||||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
||||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
||||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
||||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
||||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
||||||
* PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
@@ -1,150 +0,0 @@
|
|||||||
#include "global.h"
|
|
||||||
#include "MemoryCardDriverThreaded_Xbox.h"
|
|
||||||
#include "RageUtil.h"
|
|
||||||
#include "RageLog.h"
|
|
||||||
|
|
||||||
MemoryCardDriverThreaded_Xbox::MemoryCardDriverThreaded_Xbox()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
MemoryCardDriverThreaded_Xbox::~MemoryCardDriverThreaded_Xbox()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool TestReady( const RString &sDrive, RString &sVolumeLabelOut )
|
|
||||||
{
|
|
||||||
TCHAR szVolumeNameBuffer[MAX_PATH];
|
|
||||||
DWORD dwVolumeSerialNumber;
|
|
||||||
DWORD dwMaximumComponentLength;
|
|
||||||
DWORD lpFileSystemFlags;
|
|
||||||
TCHAR szFileSystemNameBuffer[MAX_PATH];
|
|
||||||
|
|
||||||
if( !GetVolumeInformation(
|
|
||||||
sDrive,
|
|
||||||
szVolumeNameBuffer,
|
|
||||||
sizeof(szVolumeNameBuffer),
|
|
||||||
&dwVolumeSerialNumber,
|
|
||||||
&dwMaximumComponentLength,
|
|
||||||
&lpFileSystemFlags,
|
|
||||||
szFileSystemNameBuffer,
|
|
||||||
sizeof(szFileSystemNameBuffer)) ){
|
|
||||||
LOG->Trace("GetVolumeInformation failed %u", GetLastError());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
sVolumeLabelOut = szVolumeNameBuffer;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MemoryCardDriverThreaded_Xbox::TestWrite( UsbStorageDevice* pDevice )
|
|
||||||
{
|
|
||||||
/* Try to write a file, to check if the device is writable and that we have write permission.*/
|
|
||||||
for( int i = 0; i < 10; ++i )
|
|
||||||
{
|
|
||||||
HANDLE hFile = CreateFile(
|
|
||||||
ssprintf( "%s\\tmp%i", pDevice->sOsMountDir.c_str(), RandomInt(100000)),
|
|
||||||
GENERIC_WRITE,
|
|
||||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
|
||||||
NULL,
|
|
||||||
CREATE_NEW,
|
|
||||||
FILE_FLAG_DELETE_ON_CLOSE,
|
|
||||||
NULL );
|
|
||||||
|
|
||||||
if( hFile == INVALID_HANDLE_VALUE )
|
|
||||||
{
|
|
||||||
DWORD iError = GetLastError();
|
|
||||||
LOG->Warn( "Couldn't write to %s (%u)", pDevice->sOsMountDir.c_str(), iError);
|
|
||||||
|
|
||||||
if( iError == ERROR_FILE_EXISTS )
|
|
||||||
continue;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
CloseHandle( hFile );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
pDevice->SetError( "TestFailed" );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MemoryCardDriverThreaded_Xbox::GetUSBStorageDevices( vector<UsbStorageDevice>& vDevicesOut )
|
|
||||||
{
|
|
||||||
DWORD devices=XGetDevices(XDEVICE_TYPE_MEMORY_UNIT);
|
|
||||||
|
|
||||||
for(int port=0;port<4;port++){
|
|
||||||
//top slot
|
|
||||||
if(devices&(1<<port)){
|
|
||||||
vDevicesOut.push_back( UsbStorageDevice() );
|
|
||||||
UsbStorageDevice &usbd = vDevicesOut.back();
|
|
||||||
usbd.iPort=port;
|
|
||||||
usbd.iLevel=0;
|
|
||||||
usbd.sDevice=ssprintf("Memory card on port %u on slot 0", port);
|
|
||||||
}
|
|
||||||
//bottom slot
|
|
||||||
if(devices&(1<<(port+16))){
|
|
||||||
vDevicesOut.push_back( UsbStorageDevice() );
|
|
||||||
UsbStorageDevice &usbd = vDevicesOut.back();
|
|
||||||
usbd.iPort=port;
|
|
||||||
usbd.iLevel=1;
|
|
||||||
usbd.sDevice=ssprintf("Memory card on port %u on slot 1", port);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MemoryCardDriverThreaded_Xbox::USBStorageDevicesChanged()
|
|
||||||
{
|
|
||||||
DWORD ins, rem;
|
|
||||||
return XGetDeviceChanges(XDEVICE_TYPE_MEMORY_UNIT, &ins, &rem)==TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MemoryCardDriverThreaded_Xbox::Mount( UsbStorageDevice* pDevice )
|
|
||||||
{
|
|
||||||
LOG->Trace( "%s", __FUNCTION__);
|
|
||||||
CHAR drive;
|
|
||||||
DWORD MountRetval=XMountMU(pDevice->iPort, pDevice->iLevel, &drive);
|
|
||||||
if(MountRetval==ERROR_SUCCESS){
|
|
||||||
LOG->Trace("Mounted memory card from port %u slot %u to %c:", pDevice->iPort, pDevice->iLevel, drive);
|
|
||||||
pDevice->SetOsMountDir(ssprintf("%c:", drive));
|
|
||||||
RString sVolumeLabel;
|
|
||||||
if( !TestReady(pDevice->sOsMountDir + "\\", sVolumeLabel) )
|
|
||||||
{
|
|
||||||
LOG->Trace( "not TestReady" );
|
|
||||||
}
|
|
||||||
pDevice->sVolumeLabel = sVolumeLabel;
|
|
||||||
return true;
|
|
||||||
}else{
|
|
||||||
LOG->Trace("Could not mount memory card %u", MountRetval);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MemoryCardDriverThreaded_Xbox::Unmount( UsbStorageDevice* pDevice )
|
|
||||||
{
|
|
||||||
XUnmountMU(pDevice->iPort, pDevice->iLevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (c) 2003-2004 Chris Danford
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
||||||
* whom the Software is furnished to do so, provided that the above
|
|
||||||
* copyright notice(s) and this permission notice appear in all copies of
|
|
||||||
* the Software and that both the above copyright notice(s) and this
|
|
||||||
* permission notice appear in supporting documentation.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
||||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
||||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
||||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
||||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
||||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
||||||
* PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
#ifndef MemoryCardDriverThreaded_Xbox_H
|
|
||||||
#define MemoryCardDriverThreaded_Xbox_H
|
|
||||||
|
|
||||||
#include "MemoryCardDriver.h"
|
|
||||||
|
|
||||||
class MemoryCardDriverThreaded_Xbox: public MemoryCardDriver
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MemoryCardDriverThreaded_Xbox();
|
|
||||||
virtual ~MemoryCardDriverThreaded_Xbox();
|
|
||||||
|
|
||||||
virtual bool Mount( UsbStorageDevice* pDevice );
|
|
||||||
virtual void Unmount( UsbStorageDevice* pDevice );
|
|
||||||
|
|
||||||
private:
|
|
||||||
void GetUSBStorageDevices( vector<UsbStorageDevice>& vDevicesOut );
|
|
||||||
bool USBStorageDevicesChanged();
|
|
||||||
bool TestWrite( UsbStorageDevice* pDevice );
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef ARCH_MEMORY_CARD_DRIVER
|
|
||||||
#error "More than one MemoryCardDriver included!"
|
|
||||||
#endif
|
|
||||||
#define ARCH_MEMORY_CARD_DRIVER MemoryCardDriverThreaded_Xbox
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (c) 2003-2004 Chris Danford
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
||||||
* whom the Software is furnished to do so, provided that the above
|
|
||||||
* copyright notice(s) and this permission notice appear in all copies of
|
|
||||||
* the Software and that both the above copyright notice(s) and this
|
|
||||||
* permission notice appear in supporting documentation.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
||||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
||||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
||||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
||||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
||||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
||||||
* PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
@@ -29,34 +29,15 @@ namespace avcodec
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#if defined(_MSC_VER) && !defined(XBOX)
|
#if defined(_MSC_VER)
|
||||||
#pragma comment(lib, "ffmpeg/lib/avcodec.lib")
|
#pragma comment(lib, "ffmpeg/lib/avcodec.lib")
|
||||||
#pragma comment(lib, "ffmpeg/lib/avformat.lib")
|
#pragma comment(lib, "ffmpeg/lib/avformat.lib")
|
||||||
#if defined(USE_MODERN_FFMPEG)
|
#if defined(USE_MODERN_FFMPEG)
|
||||||
#pragma comment(lib, "ffmpeg/lib/swscale.lib")
|
#pragma comment(lib, "ffmpeg/lib/swscale.lib")
|
||||||
#endif
|
#endif
|
||||||
#endif // _MSC_VER && !XBOX
|
#endif // _MSC_VER
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(XBOX)
|
|
||||||
/* NOTES: ffmpeg static libraries arent included in SVN. You have to build
|
|
||||||
*them yourself or remove this file to produce the xbox build.
|
|
||||||
*
|
|
||||||
* build ffmpeg with mingw32 ( howto http://ffmpeg.arrozcru.org/wiki/index.php?title=Main_Page )
|
|
||||||
* ./configure --enable-memalign-hack --enable-static --disable-mmx --target-os=mingw32 --arch=x86
|
|
||||||
* you can use various switches to enable/disable codecs/muxers/etc.
|
|
||||||
*
|
|
||||||
* libgcc.a and libmingwex.a comes from mingw installation
|
|
||||||
* msys\mingw\lib\gcc\mingw32\3.4.5\libgcc.a */
|
|
||||||
#pragma comment(lib, "ffmpeg/lib/libavcodec.a")
|
|
||||||
#pragma comment(lib, "ffmpeg/lib/libavformat.a")
|
|
||||||
#pragma comment(lib, "ffmpeg/lib/libavutil.a")
|
|
||||||
#pragma comment(lib, "ffmpeg/lib/libswscale.a")
|
|
||||||
#pragma comment(lib, "ffmpeg/lib/libgcc.a")
|
|
||||||
#pragma comment(lib, "ffmpeg/lib/libmingwex.a")
|
|
||||||
#pragma comment(lib, "ffmpeg/lib/libcoldname.a")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(MACOSX)
|
#if !defined(MACOSX)
|
||||||
static const int sws_flags = SWS_BICUBIC; // XXX: Reasonable default?
|
static const int sws_flags = SWS_BICUBIC; // XXX: Reasonable default?
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include "RageUtil.h"
|
#include "RageUtil.h"
|
||||||
#include "Sprite.h"
|
#include "Sprite.h"
|
||||||
|
|
||||||
#if defined(WIN32) && !defined(XBOX)
|
#if defined(WIN32)
|
||||||
#include "archutils/Win32/ErrorStrings.h"
|
#include "archutils/Win32/ErrorStrings.h"
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -31,11 +31,9 @@ HANDLE Win32ThreadIdToHandle( uint64_t iID )
|
|||||||
|
|
||||||
void ThreadImpl_Win32::Halt( bool Kill )
|
void ThreadImpl_Win32::Halt( bool Kill )
|
||||||
{
|
{
|
||||||
#ifndef _XBOX
|
|
||||||
if( Kill )
|
if( Kill )
|
||||||
TerminateThread( ThreadHandle, 0 );
|
TerminateThread( ThreadHandle, 0 );
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
SuspendThread( ThreadHandle );
|
SuspendThread( ThreadHandle );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-9
@@ -52,9 +52,6 @@ void MakeInputHandlers( const RString &drivers, vector<InputHandler *> &Add )
|
|||||||
#ifdef USE_INPUT_HANDLER_X11
|
#ifdef USE_INPUT_HANDLER_X11
|
||||||
if( !s->CompareNoCase("X11") ) ret = new InputHandler_X11;
|
if( !s->CompareNoCase("X11") ) ret = new InputHandler_X11;
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_INPUT_HANDLER_XBOX
|
|
||||||
if( !s->CompareNoCase("Xbox") ) ret = new InputHandler_Xbox;
|
|
||||||
#endif
|
|
||||||
#ifdef USE_INPUT_HANDLER_MACOSX_HID
|
#ifdef USE_INPUT_HANDLER_MACOSX_HID
|
||||||
if( !s->CompareNoCase("MacOSX") ) ret = new InputHandler_MacOSX_HID;
|
if( !s->CompareNoCase("MacOSX") ) ret = new InputHandler_MacOSX_HID;
|
||||||
#endif
|
#endif
|
||||||
@@ -104,7 +101,7 @@ LoadingWindow *MakeLoadingWindow()
|
|||||||
return new LoadingWindow_Null;
|
return new LoadingWindow_Null;
|
||||||
#endif
|
#endif
|
||||||
// Don't load NULL by default.
|
// Don't load NULL by default.
|
||||||
const RString drivers = "xbox,win32,cocoa,gtk";
|
const RString drivers = "win32,cocoa,gtk";
|
||||||
vector<RString> DriversToTry;
|
vector<RString> DriversToTry;
|
||||||
split( drivers, ",", DriversToTry, true );
|
split( drivers, ",", DriversToTry, true );
|
||||||
|
|
||||||
@@ -129,10 +126,6 @@ LoadingWindow *MakeLoadingWindow()
|
|||||||
#ifdef USE_LOADING_WINDOW_WIN32
|
#ifdef USE_LOADING_WINDOW_WIN32
|
||||||
if( !DriversToTry[i].CompareNoCase("Win32") ) ret = new LoadingWindow_Win32;
|
if( !DriversToTry[i].CompareNoCase("Win32") ) ret = new LoadingWindow_Win32;
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_LOADING_WINDOW_XBOX
|
|
||||||
if( !DriversToTry[i].CompareNoCase("Xbox") ) ret = new LoadingWindow_Xbox;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
if( ret == NULL )
|
if( ret == NULL )
|
||||||
continue;
|
continue;
|
||||||
@@ -231,7 +224,7 @@ RageMovieTexture *MakeRageMovieTexture( RageTextureID ID )
|
|||||||
RageException::Throw( COULDNT_CREATE_MOVIE_DRIVER.GetValue() );
|
RageException::Throw( COULDNT_CREATE_MOVIE_DRIVER.GetValue() );
|
||||||
|
|
||||||
LOG->Trace( "Created movie texture \"%s\" with driver \"%s\"",
|
LOG->Trace( "Created movie texture \"%s\" with driver \"%s\"",
|
||||||
ID.filename.c_str(), Driver.c_str() );
|
ID.filename.c_str(), Driver.c_str() );
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,6 @@
|
|||||||
#if defined(_WINDOWS)
|
#if defined(_WINDOWS)
|
||||||
#define SUPPORT_OPENGL
|
#define SUPPORT_OPENGL
|
||||||
#define SUPPORT_D3D
|
#define SUPPORT_D3D
|
||||||
#elif defined(_XBOX)
|
|
||||||
#define SUPPORT_D3D
|
|
||||||
#else
|
#else
|
||||||
#define SUPPORT_OPENGL
|
#define SUPPORT_OPENGL
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -22,16 +22,6 @@
|
|||||||
#define DEFAULT_SOUND_DRIVER_LIST "AudioUnit,Null"
|
#define DEFAULT_SOUND_DRIVER_LIST "AudioUnit,Null"
|
||||||
|
|
||||||
|
|
||||||
#elif defined(_XBOX)
|
|
||||||
#include "ArchHooks/ArchHooks_Xbox.h"
|
|
||||||
#include "LoadingWindow/LoadingWindow_Xbox.h"
|
|
||||||
#include "LowLevelWindow/LowLevelWindow_Win32.h"
|
|
||||||
#include "MemoryCard/MemoryCardDriverThreaded_Xbox.h"
|
|
||||||
#define DEFAULT_INPUT_DRIVER_LIST "Xbox"
|
|
||||||
#define DEFAULT_MOVIE_DRIVER_LIST "Theora,FFMpeg,DShow,Null"
|
|
||||||
#define DEFAULT_SOUND_DRIVER_LIST "DirectSound,DirectSound-sw,Null"
|
|
||||||
|
|
||||||
|
|
||||||
#elif defined(UNIX)
|
#elif defined(UNIX)
|
||||||
#include "ArchHooks/ArchHooks_Unix.h"
|
#include "ArchHooks/ArchHooks_Unix.h"
|
||||||
#include "LowLevelWindow/LowLevelWindow_X11.h"
|
#include "LowLevelWindow/LowLevelWindow_X11.h"
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
#ifndef APP_INSTANCE_H
|
#ifndef APP_INSTANCE_H
|
||||||
#define APP_INSTANCE_H
|
#define APP_INSTANCE_H
|
||||||
|
|
||||||
#if !defined(_XBOX)
|
#include "windows.h"
|
||||||
# include "windows.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** @brief get an HINSTANCE for starting dialog boxes. */
|
/** @brief get an HINSTANCE for starting dialog boxes. */
|
||||||
class AppInstance
|
class AppInstance
|
||||||
|
|||||||
@@ -2,14 +2,10 @@
|
|||||||
#include "DirectXHelpers.h"
|
#include "DirectXHelpers.h"
|
||||||
#include "RageUtil.h"
|
#include "RageUtil.h"
|
||||||
|
|
||||||
#ifdef _XBOX
|
#include <windows.h>
|
||||||
# include <D3DX8Core.h>
|
#include <dxerr8.h>
|
||||||
#else
|
#if defined(_MSC_VER)
|
||||||
# include <windows.h>
|
# pragma comment(lib, "dxerr8.lib")
|
||||||
# include <dxerr8.h>
|
|
||||||
# if defined(_MSC_VER)
|
|
||||||
# pragma comment(lib, "dxerr8.lib")
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RString hr_ssprintf( int hr, const char *fmt, ... )
|
RString hr_ssprintf( int hr, const char *fmt, ... )
|
||||||
@@ -19,13 +15,7 @@ RString hr_ssprintf( int hr, const char *fmt, ... )
|
|||||||
RString s = vssprintf( fmt, va );
|
RString s = vssprintf( fmt, va );
|
||||||
va_end(va);
|
va_end(va);
|
||||||
|
|
||||||
#ifdef _XBOX
|
|
||||||
char szError[1024] = "";
|
|
||||||
D3DXGetErrorString( hr, szError, sizeof(szError) );
|
|
||||||
#else
|
|
||||||
const char *szError = DXGetErrorString8( hr );
|
const char *szError = DXGetErrorString8( hr );
|
||||||
#endif
|
|
||||||
|
|
||||||
return s + ssprintf( " (%s)", szError );
|
return s + ssprintf( " (%s)", szError );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,17 +2,13 @@
|
|||||||
#include "ErrorStrings.h"
|
#include "ErrorStrings.h"
|
||||||
#include "RageUtil.h"
|
#include "RageUtil.h"
|
||||||
|
|
||||||
#if !defined(XBOX)
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
RString werr_ssprintf( int err, const char *fmt, ... )
|
RString werr_ssprintf( int err, const char *fmt, ... )
|
||||||
{
|
{
|
||||||
char buf[1024] = "";
|
char buf[1024] = "";
|
||||||
#ifndef _XBOX
|
|
||||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
|
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
|
||||||
0, err, 0, buf, sizeof(buf), NULL);
|
0, err, 0, buf, sizeof(buf), NULL);
|
||||||
#endif
|
|
||||||
|
|
||||||
// Why is FormatMessage returning text ending with \r\n? (who? -aj)
|
// Why is FormatMessage returning text ending with \r\n? (who? -aj)
|
||||||
// Perhaps it's because you're on Windows, where newlines are \r\n. -aj
|
// Perhaps it's because you're on Windows, where newlines are \r\n. -aj
|
||||||
|
|||||||
@@ -1,14 +1,10 @@
|
|||||||
#ifndef ARCH_SETUP_WINDOWS_H
|
#ifndef ARCH_SETUP_WINDOWS_H
|
||||||
#define ARCH_SETUP_WINDOWS_H
|
#define ARCH_SETUP_WINDOWS_H
|
||||||
|
|
||||||
#if !defined(XBOX)
|
|
||||||
#define HAVE_FFMPEG
|
#define HAVE_FFMPEG
|
||||||
#define HAVE_THEORA
|
#define HAVE_THEORA
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(XBOX)
|
|
||||||
#define SUPPORT_OPENGL
|
#define SUPPORT_OPENGL
|
||||||
#endif
|
|
||||||
#define SUPPORT_D3D
|
#define SUPPORT_D3D
|
||||||
|
|
||||||
#if defined(__MINGW32__)
|
#if defined(__MINGW32__)
|
||||||
@@ -143,25 +139,13 @@ inline long int lrintf( float f )
|
|||||||
|
|
||||||
/* We implement the crash handler interface (though that interface isn't
|
/* We implement the crash handler interface (though that interface isn't
|
||||||
* completely uniform across platforms yet). */
|
* completely uniform across platforms yet). */
|
||||||
#if !defined(_XBOX) && !defined(SMPACKAGE)
|
#if !defined(SMPACKAGE)
|
||||||
#define CRASH_HANDLER
|
#define CRASH_HANDLER
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ENDIAN_LITTLE
|
#define ENDIAN_LITTLE
|
||||||
|
|
||||||
#if defined(_XBOX)
|
|
||||||
#if defined(_DEBUG)
|
|
||||||
#define OGG_LIB_DIR "vorbis/xbox/debug/"
|
|
||||||
#else
|
|
||||||
#define OGG_LIB_DIR "vorbis/xbox/release/"
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#define OGG_LIB_DIR "vorbis/win32/"
|
#define OGG_LIB_DIR "vorbis/win32/"
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(XBOX)
|
|
||||||
#include "ArchUtils/Xbox/arch_setup.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__GNUC__) // It might be MinGW or Cygwin(?)
|
#if defined(__GNUC__) // It might be MinGW or Cygwin(?)
|
||||||
#include "archutils/Common/gcc_byte_swaps.h"
|
#include "archutils/Common/gcc_byte_swaps.h"
|
||||||
|
|||||||
@@ -1,151 +0,0 @@
|
|||||||
#include "global.h"
|
|
||||||
#include "archutils/Xbox/GraphicsWindow.h"
|
|
||||||
#include "ProductInfo.h"
|
|
||||||
#include "RageLog.h"
|
|
||||||
#include "RageUtil.h"
|
|
||||||
#include "RageDisplay.h"
|
|
||||||
|
|
||||||
static const RString g_sClassName = RString(PRODUCT_ID) + " LowLevelWindow_Win32";
|
|
||||||
|
|
||||||
static VideoModeParams g_CurrentParams;
|
|
||||||
static bool g_bResolutionChanged = false;
|
|
||||||
static bool g_bHasFocus = true;
|
|
||||||
static bool g_bLastHasFocus = true;
|
|
||||||
static bool m_bWideWindowClass;
|
|
||||||
bool isPALSystem();
|
|
||||||
void setScreenResolutionValues();
|
|
||||||
|
|
||||||
void GraphicsWindow::SetVideoModeParams( const VideoModeParams ¶ms )
|
|
||||||
{
|
|
||||||
g_CurrentParams = params;
|
|
||||||
}
|
|
||||||
|
|
||||||
const VideoModeParams &GraphicsWindow::GetParams()
|
|
||||||
{
|
|
||||||
return g_CurrentParams;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GraphicsWindow::Update()
|
|
||||||
{
|
|
||||||
if( g_bResolutionChanged )
|
|
||||||
{
|
|
||||||
/* Let DISPLAY know that our resolution has changed. */
|
|
||||||
DISPLAY->ResolutionChanged();
|
|
||||||
g_bResolutionChanged = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GraphicsWindow::Initialize( bool bD3D )
|
|
||||||
{
|
|
||||||
/* We do the parameters initialisation here. No need to use the INI,
|
|
||||||
because if we changed resolutions, it wouldn't keep up. */
|
|
||||||
|
|
||||||
g_CurrentParams.bpp = 32;
|
|
||||||
g_CurrentParams.windowed=false;
|
|
||||||
|
|
||||||
isPALSystem();
|
|
||||||
setScreenResolutionValues();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isPALSystem()
|
|
||||||
{
|
|
||||||
if(XGetVideoStandard() == XC_VIDEO_STANDARD_PAL_I)
|
|
||||||
{
|
|
||||||
g_CurrentParams.interlaced=true;
|
|
||||||
|
|
||||||
/* Get supported video flags. */
|
|
||||||
DWORD VideoFlags = XGetVideoFlags();
|
|
||||||
|
|
||||||
/* Set pal60 if available. */
|
|
||||||
if( VideoFlags & XC_VIDEO_FLAGS_PAL_60Hz )
|
|
||||||
g_CurrentParams.rate = 60;
|
|
||||||
else
|
|
||||||
g_CurrentParams.rate = 50;
|
|
||||||
|
|
||||||
g_CurrentParams.PAL = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
g_CurrentParams.rate = 60;
|
|
||||||
g_CurrentParams.PAL = false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
void setScreenResolutionValues()
|
|
||||||
{
|
|
||||||
DWORD CurrentVideoFlags = XGetVideoFlags();
|
|
||||||
int heightStandards;
|
|
||||||
|
|
||||||
// Preventive definition. Changed only if needed.
|
|
||||||
g_CurrentParams.interlaced=false;
|
|
||||||
|
|
||||||
switch(isPALSystem()){
|
|
||||||
case true:
|
|
||||||
heightStandards = 576;
|
|
||||||
break;
|
|
||||||
case false:
|
|
||||||
heightStandards = 480;
|
|
||||||
g_CurrentParams.interlaced=false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (CurrentVideoFlags){
|
|
||||||
|
|
||||||
case XC_VIDEO_FLAGS_HDTV_480p:
|
|
||||||
g_CurrentParams.width=720;
|
|
||||||
g_CurrentParams.height=480;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case XC_VIDEO_FLAGS_HDTV_720p:
|
|
||||||
g_CurrentParams.width=1280;
|
|
||||||
g_CurrentParams.height=720;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case XC_VIDEO_FLAGS_HDTV_1080i:
|
|
||||||
g_CurrentParams.width=1920;
|
|
||||||
g_CurrentParams.height=1080;
|
|
||||||
g_CurrentParams.interlaced=true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case XC_VIDEO_FLAGS_WIDESCREEN:
|
|
||||||
g_CurrentParams.width=720;
|
|
||||||
g_CurrentParams.height=heightStandards;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case XC_VIDEO_FLAGS_LETTERBOX:
|
|
||||||
default:
|
|
||||||
g_CurrentParams.width=640;
|
|
||||||
g_CurrentParams.height=heightStandards;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GraphicsWindow::Shutdown() { }
|
|
||||||
RString GraphicsWindow::SetScreenMode( const VideoModeParams &p ) { return ""; }
|
|
||||||
void GraphicsWindow::CreateGraphicsWindow( const VideoModeParams &p ) { }
|
|
||||||
void GraphicsWindow::RecreateGraphicsWindow( const VideoModeParams &p ) { }
|
|
||||||
void GraphicsWindow::DestroyGraphicsWindow() { }
|
|
||||||
void GraphicsWindow::ConfigureGraphicsWindow( const VideoModeParams &p ) { }
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (c) 2004 Glenn Maynard, Renaud Lepage
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
||||||
* whom the Software is furnished to do so, provided that the above
|
|
||||||
* copyright notice(s) and this permission notice appear in all copies of
|
|
||||||
* the Software and that both the above copyright notice(s) and this
|
|
||||||
* permission notice appear in supporting documentation.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
||||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
||||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
||||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
||||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
||||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
||||||
* PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
#if !defined(GRAPHICS_WINDOW_H)
|
|
||||||
#define GRAPHICS_WINDOW_H
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
class VideoModeParams;
|
|
||||||
|
|
||||||
namespace GraphicsWindow
|
|
||||||
{
|
|
||||||
void Initialize( bool bD3D );
|
|
||||||
void Shutdown();
|
|
||||||
void SetVideoModeParams( const VideoModeParams &p );
|
|
||||||
RString SetScreenMode( const VideoModeParams &p );
|
|
||||||
void CreateGraphicsWindow( const VideoModeParams &p );
|
|
||||||
void RecreateGraphicsWindow( const VideoModeParams &p );
|
|
||||||
void DestroyGraphicsWindow();
|
|
||||||
void ConfigureGraphicsWindow( const VideoModeParams &p );
|
|
||||||
const VideoModeParams &GetParams();
|
|
||||||
void Update();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (c) 2004 Glenn Maynard
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
||||||
* whom the Software is furnished to do so, provided that the above
|
|
||||||
* copyright notice(s) and this permission notice appear in all copies of
|
|
||||||
* the Software and that both the above copyright notice(s) and this
|
|
||||||
* permission notice appear in supporting documentation.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
||||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
||||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
||||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
||||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
||||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
||||||
* PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
@@ -1,644 +0,0 @@
|
|||||||
/* This handles manual paging. It's primarily intended for the Xbox, but works
|
|
||||||
* in Windows as well; it can be enabled for debugging. */
|
|
||||||
|
|
||||||
#include "global.h"
|
|
||||||
#include "VirtualMemory.h"
|
|
||||||
#include "RageLog.h"
|
|
||||||
#include "Preference.h"
|
|
||||||
#include <new>
|
|
||||||
|
|
||||||
#if defined(WINDOWS)
|
|
||||||
#define PAGE_FILE_PATH "StepMania pagefile.dat"
|
|
||||||
#else
|
|
||||||
#define PAGE_FILE_PATH "Z:\\xxpagefile.sys"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
VirtualMemoryManager vmem_Manager;
|
|
||||||
|
|
||||||
static Preference<bool> g_bEnableVirtualMemory( "EnableVirtualMemory", true );
|
|
||||||
// page file size in megabytes
|
|
||||||
static Preference<int> g_iPageFileSize( "PageFileSize", 384 );
|
|
||||||
// page size in kilobytes
|
|
||||||
static Preference<int> g_iPageSize( "PageSize", 16 );
|
|
||||||
// threshold in kilobytes where virtual memory will be used
|
|
||||||
static Preference<int> g_iPageThreshold( "PageThreshold", 8 );
|
|
||||||
// (under debug) log the virtual memory allocation, etc.
|
|
||||||
static Preference<bool> g_bLogVirtualMemory( "LogVirtualMemory", false );
|
|
||||||
|
|
||||||
struct vm_page
|
|
||||||
{
|
|
||||||
DWORD startAddress; // start address for this page
|
|
||||||
unsigned long headPage; // 0 if not allocated. Otherwise, the index of the first page
|
|
||||||
// of this segment.
|
|
||||||
bool committed; // true if this page is committed to RAM (is otherwise in the page file)
|
|
||||||
bool locked; // true if this page should not be decommitted
|
|
||||||
int pageFaults; // number of times this page has been accessed when it wasn't committed
|
|
||||||
unsigned long sizeInPages; // size of the data segment in pages.
|
|
||||||
size_t sizeInBytes; // size of the data segment in bytes.
|
|
||||||
};
|
|
||||||
|
|
||||||
VirtualMemoryManager::VirtualMemoryManager():
|
|
||||||
vmemMutex("VirtualMemory")
|
|
||||||
{
|
|
||||||
pages = 0;
|
|
||||||
pageLRU = -1;
|
|
||||||
inited = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
VirtualMemoryManager::~VirtualMemoryManager()
|
|
||||||
{
|
|
||||||
Destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VirtualMemoryManager::Init()
|
|
||||||
{
|
|
||||||
if( !g_bEnableVirtualMemory )
|
|
||||||
return true;
|
|
||||||
unsigned long totalPageSize = 1024 * 1024 * g_iPageFileSize;
|
|
||||||
unsigned long sizePerPage = 1024 * g_iPageSize;
|
|
||||||
unsigned long thold = 1024 * g_iPageThreshold;
|
|
||||||
|
|
||||||
threshold = thold;
|
|
||||||
|
|
||||||
totalPages = totalPageSize / sizePerPage;
|
|
||||||
pageSize = sizePerPage;
|
|
||||||
|
|
||||||
if(totalPageSize % sizePerPage != 0)
|
|
||||||
totalPageSize = sizePerPage * totalPages;
|
|
||||||
|
|
||||||
// initialise the pages array
|
|
||||||
// bypass the overridden new by using HeapAlloc
|
|
||||||
pages = (vm_page*)HeapAlloc(GetProcessHeap(), 0, totalPages * sizeof(vm_page));
|
|
||||||
|
|
||||||
if(pages == NULL)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// create the page file on Z drive
|
|
||||||
vmemFile = CreateFile( PAGE_FILE_PATH, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
|
|
||||||
|
|
||||||
if(vmemFile == INVALID_HANDLE_VALUE)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// set the file size
|
|
||||||
// find the current file size
|
|
||||||
unsigned long fileSize = SetFilePointer(vmemFile, 0, 0, FILE_END);
|
|
||||||
if(fileSize == INVALID_SET_FILE_POINTER)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if(fileSize < totalPageSize)
|
|
||||||
{
|
|
||||||
fileSize = SetFilePointer(vmemFile, totalPageSize, 0, FILE_BEGIN);
|
|
||||||
if(fileSize == INVALID_SET_FILE_POINTER)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reserve the virtual memory and get the base address
|
|
||||||
baseAddress = (DWORD)VirtualAlloc(NULL, totalPageSize, MEM_RESERVE, PAGE_NOACCESS);
|
|
||||||
|
|
||||||
if(baseAddress == NULL)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// initialise the page array
|
|
||||||
for(unsigned long i = 0; i < totalPages; i++)
|
|
||||||
{
|
|
||||||
pages[i].startAddress = baseAddress + (i * pageSize);
|
|
||||||
pages[i].headPage = -1;
|
|
||||||
pages[i].committed = false;
|
|
||||||
pages[i].sizeInPages = 0;
|
|
||||||
pages[i].sizeInBytes = 0;
|
|
||||||
pages[i].pageFaults = 0;
|
|
||||||
pages[i].locked = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetLogging( g_bLogVirtualMemory );
|
|
||||||
|
|
||||||
inited = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void VirtualMemoryManager::Destroy()
|
|
||||||
{
|
|
||||||
if(pages != 0)
|
|
||||||
{
|
|
||||||
VirtualFree((LPVOID)baseAddress, 0, MEM_RELEASE);
|
|
||||||
HeapFree(GetProcessHeap(), 0, pages);
|
|
||||||
CloseHandle(vmemFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void* VirtualMemoryManager::Allocate(size_t size)
|
|
||||||
{
|
|
||||||
if(!inited)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
LockMut(vmemMutex);
|
|
||||||
|
|
||||||
unsigned long startPage = -1;
|
|
||||||
unsigned long freeSegments = 0;
|
|
||||||
unsigned long sizeInPages = (size / pageSize) + 1;
|
|
||||||
|
|
||||||
if(size % pageSize == 0)
|
|
||||||
sizeInPages--;
|
|
||||||
|
|
||||||
// find a contiguous group of pages that will fit the data
|
|
||||||
for(unsigned long i = 0; i < totalPages; i++)
|
|
||||||
{
|
|
||||||
if(pages[i].sizeInPages != 0)
|
|
||||||
{
|
|
||||||
startPage = -1;
|
|
||||||
freeSegments = 0;
|
|
||||||
i += pages[i].sizeInPages - 1; // go to next page segment
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(startPage == -1)
|
|
||||||
{
|
|
||||||
startPage = i;
|
|
||||||
freeSegments = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
freeSegments++;
|
|
||||||
|
|
||||||
if(sizeInPages == freeSegments)
|
|
||||||
{
|
|
||||||
if(LOG && logging)
|
|
||||||
LOG->Trace("Allocating pages %u to %u", startPage, startPage + freeSegments - 1);
|
|
||||||
|
|
||||||
// commit this to memory
|
|
||||||
DWORD ret = (DWORD)VirtualAlloc((LPVOID)pages[startPage].startAddress, size, MEM_COMMIT, PAGE_READWRITE);
|
|
||||||
while(ret == NULL)
|
|
||||||
{
|
|
||||||
bool swappedOut = DecommitLRU();
|
|
||||||
|
|
||||||
if(!swappedOut)
|
|
||||||
{
|
|
||||||
if(LOG)
|
|
||||||
LOG->Trace("VMem error: out of memory with no pages to swap out left");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = (DWORD)VirtualAlloc((LPVOID)pages[startPage].startAddress, size, MEM_COMMIT, PAGE_READWRITE);
|
|
||||||
}
|
|
||||||
|
|
||||||
pageLRU = (startPage + sizeInPages) % totalPages;
|
|
||||||
for(unsigned long j = startPage; j < startPage + freeSegments; j++)
|
|
||||||
{
|
|
||||||
pages[j].headPage = startPage;
|
|
||||||
pages[j].pageFaults = 0;
|
|
||||||
pages[j].sizeInPages = freeSegments;
|
|
||||||
pages[j].sizeInBytes = size;
|
|
||||||
pages[j].committed = true;
|
|
||||||
pages[i].locked = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (void*) ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(LOG)
|
|
||||||
LOG->Trace("VMem error: Couldn't find contiguous group of pages to allocate");
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VirtualMemoryManager::Free(void *ptr)
|
|
||||||
{
|
|
||||||
if(!inited)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
LockMut(vmemMutex);
|
|
||||||
|
|
||||||
// check that the address is within the virtual address bounds
|
|
||||||
if((DWORD)ptr < baseAddress || (DWORD)ptr >= baseAddress + (totalPages * pageSize))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// find the page(s) to free
|
|
||||||
DWORD offset = (DWORD)ptr - baseAddress;
|
|
||||||
unsigned long pageIndex = offset / pageSize;
|
|
||||||
|
|
||||||
if(pages[pageIndex].headPage == -1)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
pageIndex = pages[pageIndex].headPage;
|
|
||||||
ptr = (void *)pages[pageIndex].startAddress;
|
|
||||||
|
|
||||||
unsigned long endPage = pageIndex + pages[pageIndex].sizeInPages;
|
|
||||||
unsigned long size = pages[pageIndex].sizeInBytes;
|
|
||||||
|
|
||||||
if(size == 0)
|
|
||||||
{
|
|
||||||
return false; // trying to free unallocated memory
|
|
||||||
}
|
|
||||||
|
|
||||||
if(LOG && logging)
|
|
||||||
LOG->Trace("Freeing pages %u to %u", pageIndex, endPage - 1);
|
|
||||||
|
|
||||||
if(pages[pageIndex].committed)
|
|
||||||
VirtualFree(ptr, size, MEM_DECOMMIT);
|
|
||||||
|
|
||||||
for(unsigned long i = pageIndex; i < endPage; i++)
|
|
||||||
{
|
|
||||||
pages[i].headPage = -1;
|
|
||||||
pages[i].committed = false;
|
|
||||||
pages[i].pageFaults = 0;
|
|
||||||
pages[i].sizeInBytes = 0;
|
|
||||||
pages[i].sizeInPages = 0;
|
|
||||||
pages[i].locked = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VirtualMemoryManager::PageFault(void *ptr)
|
|
||||||
{
|
|
||||||
if(!inited)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
LockMut(vmemMutex);
|
|
||||||
|
|
||||||
// check that the address is within the virtual address bounds
|
|
||||||
if((DWORD)ptr < baseAddress || (DWORD)ptr >= baseAddress + (totalPages * pageSize))
|
|
||||||
{
|
|
||||||
if(LOG)
|
|
||||||
{
|
|
||||||
LOG->Trace("Vmem error: Page fault outside virtual memory bounds");
|
|
||||||
LOG->Trace("Address: %u, bounds: %u to %u", (DWORD)ptr, baseAddress, baseAddress + (totalPages * pageSize));
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// find the page segment that the fault occurred
|
|
||||||
unsigned long offset = (DWORD)ptr - baseAddress;
|
|
||||||
unsigned long pageIndex = offset / pageSize;
|
|
||||||
|
|
||||||
|
|
||||||
unsigned long startPage = pages[pageIndex].headPage;
|
|
||||||
if(startPage == -1)
|
|
||||||
{
|
|
||||||
if(LOG)
|
|
||||||
LOG->Trace("VMem error: Trying to access memory that wasn't allocated");
|
|
||||||
// trying to access memory that wasn't allocated
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(pages[startPage].committed)
|
|
||||||
{
|
|
||||||
if(LOG && logging)
|
|
||||||
LOG->Trace("Pages appear to be committed already. Doing nothing...");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
pageLRU = (startPage + pages[startPage].sizeInPages) % totalPages;
|
|
||||||
|
|
||||||
if(LOG && logging)
|
|
||||||
LOG->Trace("Reallocating pages %u to %u", startPage, startPage + pages[startPage].sizeInPages - 1);
|
|
||||||
|
|
||||||
DWORD ret = (DWORD)VirtualAlloc((LPVOID)pages[startPage].startAddress, pages[startPage].sizeInBytes, MEM_COMMIT, PAGE_READWRITE);
|
|
||||||
|
|
||||||
while(ret == NULL)
|
|
||||||
{
|
|
||||||
bool swappedOut = DecommitLRU();
|
|
||||||
if(!swappedOut)
|
|
||||||
{
|
|
||||||
if(LOG)
|
|
||||||
LOG->Trace("VMem error: no pages left to swap out while reallocating");
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = (DWORD)VirtualAlloc((LPVOID)pages[startPage].startAddress, pages[startPage].sizeInBytes, MEM_COMMIT, PAGE_READWRITE);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(unsigned long i = startPage; i < startPage + pages[startPage].sizeInPages; i++)
|
|
||||||
{
|
|
||||||
pages[i].committed = true;
|
|
||||||
pages[i].pageFaults++;
|
|
||||||
}
|
|
||||||
|
|
||||||
DWORD numRead;
|
|
||||||
|
|
||||||
SetFilePointer(vmemFile, pages[startPage].startAddress - baseAddress, 0, FILE_BEGIN);
|
|
||||||
ReadFile(vmemFile, (void *)pages[startPage].startAddress, pages[startPage].sizeInBytes, &numRead, NULL);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VirtualMemoryManager::DecommitLRU()
|
|
||||||
{
|
|
||||||
if(!inited)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
LockMut(vmemMutex);
|
|
||||||
|
|
||||||
// choose random LRU
|
|
||||||
pageLRU = rand() % totalPages;
|
|
||||||
|
|
||||||
for(unsigned long i = 0; i < totalPages; i++)
|
|
||||||
{
|
|
||||||
unsigned long index = (pageLRU + i) % totalPages;
|
|
||||||
|
|
||||||
if(index == 0)
|
|
||||||
index++;
|
|
||||||
|
|
||||||
if(pages[index].headPage == index && pages[index].committed && !pages[index].locked) // this is a head page
|
|
||||||
{
|
|
||||||
DWORD addr = pages[index].startAddress;
|
|
||||||
unsigned long size = pages[index].sizeInPages;
|
|
||||||
|
|
||||||
// decommit this page
|
|
||||||
// write to the page file
|
|
||||||
if(SetFilePointer(vmemFile, addr - baseAddress, 0, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
|
|
||||||
{
|
|
||||||
if(LOG)
|
|
||||||
LOG->Trace("Vmem error: could not write to page file");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
DWORD written;
|
|
||||||
|
|
||||||
WriteFile(vmemFile, (LPCVOID)addr, pages[index].sizeInBytes, &written, NULL);
|
|
||||||
|
|
||||||
// reset the page data
|
|
||||||
if(LOG && logging)
|
|
||||||
LOG->Trace("Swapping out pages %i to %i", index, index + size - 1);
|
|
||||||
|
|
||||||
for(unsigned long j = index; j < index + size; j++)
|
|
||||||
{
|
|
||||||
pages[j].committed = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(VirtualFree((LPVOID)addr, pages[index].sizeInBytes, MEM_DECOMMIT) == 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
pageLRU = (pageLRU + pages[index].sizeInPages) % totalPages;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VirtualMemoryManager::EnsureFreeMemory(size_t size)
|
|
||||||
{
|
|
||||||
if(!inited)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
LockMut(vmemMutex);
|
|
||||||
|
|
||||||
MEMORYSTATUS ms;
|
|
||||||
GlobalMemoryStatus(&ms);
|
|
||||||
|
|
||||||
while(ms.dwAvailPhys < size)
|
|
||||||
{
|
|
||||||
if(LOG && logging)
|
|
||||||
LOG->Trace("Freeing memory: need %i, have %i", size, ms.dwAvailPhys);
|
|
||||||
|
|
||||||
if(!DecommitLRU())
|
|
||||||
{
|
|
||||||
if(LOG)
|
|
||||||
LOG->Trace("VMem error: No pages left to free while reserving memory");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void VirtualMemoryManager::Lock(void *ptr)
|
|
||||||
{
|
|
||||||
if(!inited)
|
|
||||||
return;
|
|
||||||
|
|
||||||
LockMut(vmemMutex);
|
|
||||||
|
|
||||||
// check that the address is within the virtual address bounds
|
|
||||||
if((DWORD)ptr < baseAddress || (DWORD)ptr >= baseAddress + (totalPages * pageSize))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// find the page(s) to free
|
|
||||||
DWORD offset = (DWORD)ptr - baseAddress;
|
|
||||||
unsigned long pageIndex = offset / pageSize;
|
|
||||||
|
|
||||||
if(pages[pageIndex].headPage == -1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
pageIndex = pages[pageIndex].headPage;
|
|
||||||
|
|
||||||
unsigned long endPage = pageIndex + pages[pageIndex].sizeInPages;
|
|
||||||
|
|
||||||
if(!pages[pageIndex].committed)
|
|
||||||
{
|
|
||||||
if(!PageFault(ptr))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(unsigned long i = pageIndex; i < endPage; i++)
|
|
||||||
{
|
|
||||||
pages[i].locked = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void VirtualMemoryManager::Unlock(void *ptr)
|
|
||||||
{
|
|
||||||
if(!inited)
|
|
||||||
return;
|
|
||||||
|
|
||||||
LockMut(vmemMutex);
|
|
||||||
|
|
||||||
// check that the address is within the virtual address bounds
|
|
||||||
if((DWORD)ptr < baseAddress || (DWORD)ptr >= baseAddress + (totalPages * pageSize))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// find the page(s) to free
|
|
||||||
DWORD offset = (DWORD)ptr - baseAddress;
|
|
||||||
unsigned long pageIndex = offset / pageSize;
|
|
||||||
|
|
||||||
if(pages[pageIndex].headPage == -1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
pageIndex = pages[pageIndex].headPage;
|
|
||||||
|
|
||||||
unsigned long endPage = pageIndex + pages[pageIndex].sizeInPages;
|
|
||||||
|
|
||||||
for(unsigned long i = pageIndex; i < endPage; i++)
|
|
||||||
{
|
|
||||||
pages[i].locked = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void* operator new (size_t size)
|
|
||||||
{
|
|
||||||
if(!vmem_Manager.IsValid())
|
|
||||||
return HeapAlloc(GetProcessHeap(), 0, size);
|
|
||||||
|
|
||||||
if(size > vmem_Manager.GetThreshold())
|
|
||||||
return vmem_Manager.Allocate(size);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
void *ret = HeapAlloc(GetProcessHeap(), 0, size);
|
|
||||||
while(ret == NULL)
|
|
||||||
{
|
|
||||||
if(!vmem_Manager.DecommitLRU())
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
ret = HeapAlloc(GetProcessHeap(), 0, size);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void* operator new[] (size_t size)
|
|
||||||
{
|
|
||||||
if(!vmem_Manager.IsValid())
|
|
||||||
return HeapAlloc(GetProcessHeap(), 0, size);
|
|
||||||
|
|
||||||
if(size > vmem_Manager.GetThreshold())
|
|
||||||
return vmem_Manager.Allocate(size);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
void *ret = HeapAlloc(GetProcessHeap(), 0, size);
|
|
||||||
while(ret == NULL)
|
|
||||||
{
|
|
||||||
if(!vmem_Manager.DecommitLRU())
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
ret = HeapAlloc(GetProcessHeap(), 0, size);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator delete (void *p)
|
|
||||||
{
|
|
||||||
if(vmem_Manager.IsValid())
|
|
||||||
{
|
|
||||||
if(vmem_Manager.Free(p))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, p);
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator delete[] (void *p)
|
|
||||||
{
|
|
||||||
if(vmem_Manager.IsValid())
|
|
||||||
{
|
|
||||||
if(vmem_Manager.Free(p))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, p);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *valloc(size_t size)
|
|
||||||
{
|
|
||||||
if(!vmem_Manager.IsValid())
|
|
||||||
return HeapAlloc(GetProcessHeap(), 0, size);
|
|
||||||
|
|
||||||
if(size > vmem_Manager.GetThreshold())
|
|
||||||
return vmem_Manager.Allocate(size);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
void *ret = HeapAlloc(GetProcessHeap(), 0, size);
|
|
||||||
while(ret == NULL)
|
|
||||||
{
|
|
||||||
if(!vmem_Manager.DecommitLRU())
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
ret = HeapAlloc(GetProcessHeap(), 0, size);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void vfree(void *ptr)
|
|
||||||
{
|
|
||||||
if(vmem_Manager.IsValid())
|
|
||||||
{
|
|
||||||
if(vmem_Manager.Free(ptr))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
LONG _stdcall CheckPageFault(LPEXCEPTION_POINTERS e)
|
|
||||||
{
|
|
||||||
if(LOG && e->ExceptionRecord->ExceptionCode != EXCEPTION_ACCESS_VIOLATION)
|
|
||||||
LOG->Trace("Exception: %u", e->ExceptionRecord->ExceptionCode);
|
|
||||||
|
|
||||||
if (e->ExceptionRecord->ExceptionCode != EXCEPTION_ACCESS_VIOLATION)
|
|
||||||
return EXCEPTION_CONTINUE_SEARCH;
|
|
||||||
|
|
||||||
DWORD addr = (DWORD)e->ExceptionRecord->ExceptionInformation[1];
|
|
||||||
|
|
||||||
if(vmem_Manager.IsValid())
|
|
||||||
{
|
|
||||||
if(LOG && vmem_Manager.IsLogging())
|
|
||||||
LOG->Trace("Page fault");
|
|
||||||
|
|
||||||
if(vmem_Manager.PageFault((void *)addr))
|
|
||||||
return EXCEPTION_CONTINUE_EXECUTION;
|
|
||||||
}
|
|
||||||
|
|
||||||
return EXCEPTION_CONTINUE_SEARCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
int NoMemory(size_t size)
|
|
||||||
{
|
|
||||||
if(LOG && vmem_Manager.IsLogging())
|
|
||||||
LOG->Trace("Out of memory, freeing up some...");
|
|
||||||
|
|
||||||
if(vmem_Manager.DecommitLRU())
|
|
||||||
{
|
|
||||||
if(LOG && vmem_Manager.IsLogging())
|
|
||||||
LOG->Trace("Freed some memory, trying again");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(LOG)
|
|
||||||
LOG->Trace("No memory left to free. Failed");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (c) 2004 Ryan Dortmans
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
||||||
* whom the Software is furnished to do so, provided that the above
|
|
||||||
* copyright notice(s) and this permission notice appear in all copies of
|
|
||||||
* the Software and that both the above copyright notice(s) and this
|
|
||||||
* permission notice appear in supporting documentation.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
||||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
||||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
||||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
||||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
||||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
||||||
* PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
#ifndef VIRTUAL_MEMORY_H
|
|
||||||
#define VIRTUAL_MEMORY_H
|
|
||||||
|
|
||||||
#if defined(XBOX)
|
|
||||||
#include <xtl.h>
|
|
||||||
#else
|
|
||||||
#include <windows.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "RageThreads.h"
|
|
||||||
|
|
||||||
struct vm_page;
|
|
||||||
|
|
||||||
class VirtualMemoryManager
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
VirtualMemoryManager();
|
|
||||||
~VirtualMemoryManager();
|
|
||||||
|
|
||||||
bool Init();
|
|
||||||
void Destroy();
|
|
||||||
void* Allocate(size_t size);
|
|
||||||
bool Free(void *ptr);
|
|
||||||
bool PageFault(void *ptr);
|
|
||||||
bool DecommitLRU();
|
|
||||||
bool EnsureFreeMemory(size_t size);
|
|
||||||
void Lock(void *ptr);
|
|
||||||
void Unlock(void *ptr);
|
|
||||||
void SetLogging(bool l) { logging = l; }
|
|
||||||
|
|
||||||
bool IsValid() { return inited; }
|
|
||||||
bool IsLogging() { return logging; }
|
|
||||||
unsigned long GetThreshold() { return threshold; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
vm_page *pages;
|
|
||||||
HANDLE vmemFile;
|
|
||||||
DWORD baseAddress;
|
|
||||||
unsigned long totalPages;
|
|
||||||
unsigned long pageSize;
|
|
||||||
unsigned long threshold;
|
|
||||||
unsigned long pageLRU;
|
|
||||||
|
|
||||||
bool inited;
|
|
||||||
bool logging;
|
|
||||||
|
|
||||||
// mutex to make sure pages aren't allocated/deallocated concurrently
|
|
||||||
RageMutex vmemMutex;
|
|
||||||
};
|
|
||||||
|
|
||||||
void *valloc(size_t size);
|
|
||||||
void vfree(void *ptr);
|
|
||||||
|
|
||||||
//#define malloc(size) valloc(size)
|
|
||||||
//#define free(memblock) vfree(memblock)
|
|
||||||
|
|
||||||
extern VirtualMemoryManager vmem_Manager;
|
|
||||||
|
|
||||||
LONG _stdcall CheckPageFault(LPEXCEPTION_POINTERS e);
|
|
||||||
int NoMemory(size_t size);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (c) 2004 Ryan Dortmans
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
||||||
* whom the Software is furnished to do so, provided that the above
|
|
||||||
* copyright notice(s) and this permission notice appear in all copies of
|
|
||||||
* the Software and that both the above copyright notice(s) and this
|
|
||||||
* permission notice appear in supporting documentation.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
||||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
||||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
||||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
||||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
||||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
||||||
* PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
#include "global.h"
|
|
||||||
|
|
||||||
#undef main
|
|
||||||
void __cdecl main()
|
|
||||||
{
|
|
||||||
int argc = 1;
|
|
||||||
char def[] = "default.xbe";
|
|
||||||
char *argv[] = { def };
|
|
||||||
int ret=SM_main( argc, argv );
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef _DEBUG
|
|
||||||
//release xbox libs doesnt have these functions
|
|
||||||
FILE * __cdecl _popen(const char *, const char *)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int __cdecl _pclose(FILE *)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *getenv(const char *)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int __cdecl system(const char *)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (c) 2006 Chris
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
||||||
* whom the Software is furnished to do so, provided that the above
|
|
||||||
* copyright notice(s) and this permission notice appear in all copies of
|
|
||||||
* the Software and that both the above copyright notice(s) and this
|
|
||||||
* permission notice appear in supporting documentation.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
||||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
||||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
||||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
||||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
||||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
||||||
* PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
#ifndef ARCH_SETUP_XBOX_H
|
|
||||||
#define ARCH_SETUP_XBOX_H
|
|
||||||
|
|
||||||
#include <xtl.h>
|
|
||||||
#include <xgraphics.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#if defined(_XDBG)
|
|
||||||
#include <xbdm.h>
|
|
||||||
#define IsDebuggerPresent() DmIsDebuggerPresent()
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Xbox base path
|
|
||||||
#define SYS_BASE_PATH "D:\\"
|
|
||||||
|
|
||||||
#define SUPPORT_D3D
|
|
||||||
|
|
||||||
/* Stubs: */
|
|
||||||
inline HRESULT CoInitialize( LPVOID pvReserved ) { return S_OK; }
|
|
||||||
inline void CoUninitialize() { }
|
|
||||||
|
|
||||||
extern "C" int SM_main( int argc, char *argv[] );
|
|
||||||
#define main(x,y) SM_main(x,y)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
#include <xtl.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "custom_launch_params.h"
|
|
||||||
|
|
||||||
CUSTOM_LAUNCH_DATA g_launchData ;
|
|
||||||
int g_autoLaunchGame ;
|
|
||||||
int g_launchReturnXBE ;
|
|
||||||
|
|
||||||
//XGetCustomLaunchData
|
|
||||||
//
|
|
||||||
//If there is a valid filename to load, then g_autoLaunchGame will be set to 1
|
|
||||||
//If there is a valid return XBE, then g_launchReturnXBE will be set to 1
|
|
||||||
int XGetCustomLaunchData()
|
|
||||||
{
|
|
||||||
DWORD launchType;
|
|
||||||
|
|
||||||
g_autoLaunchGame = 0 ;
|
|
||||||
g_launchReturnXBE = 0 ;
|
|
||||||
|
|
||||||
memset( &g_launchData, 0, sizeof( CUSTOM_LAUNCH_DATA ) ) ;
|
|
||||||
|
|
||||||
|
|
||||||
if ( ( XGetLaunchInfo( &launchType,(PLAUNCH_DATA)&g_launchData) == ERROR_SUCCESS ) )
|
|
||||||
{
|
|
||||||
if ( ( launchType == LDT_TITLE ) && ( g_launchData.magic == CUSTOM_LAUNCH_MAGIC ) )
|
|
||||||
{
|
|
||||||
if ( g_launchData.szFilename[0] )
|
|
||||||
g_autoLaunchGame = 1 ;
|
|
||||||
|
|
||||||
if ( g_launchData.szLaunchXBEOnExit[0] )
|
|
||||||
g_launchReturnXBE = 1 ;
|
|
||||||
|
|
||||||
return 1 ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0 ;
|
|
||||||
}
|
|
||||||
|
|
||||||
void XReturnToLaunchingXBE( )
|
|
||||||
{
|
|
||||||
if ( g_launchReturnXBE )
|
|
||||||
{
|
|
||||||
LD_LAUNCH_DASHBOARD LaunchData = { XLD_LAUNCH_DASHBOARD_MAIN_MENU };
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LD_LAUNCH_DASHBOARD LaunchData = { XLD_LAUNCH_DASHBOARD_MAIN_MENU };
|
|
||||||
|
|
||||||
XLaunchNewImage( NULL, (LAUNCH_DATA*)&LaunchData );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void doReturn()
|
|
||||||
{
|
|
||||||
XGetCustomLaunchData();
|
|
||||||
XReturnToLaunchingXBE( );
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
#ifndef CUSTOM_LAUNCH_PARAMS_H
|
|
||||||
#define CUSTOM_LAUNCH_PARAMS_H
|
|
||||||
|
|
||||||
#include <xtl.h>
|
|
||||||
|
|
||||||
|
|
||||||
#define CUSTOM_LAUNCH_MAGIC 0xEE456777
|
|
||||||
|
|
||||||
#define COUNTRY_TYPE_AUTODETECT 0
|
|
||||||
#define COUNTRY_TYPE_USA 1
|
|
||||||
#define COUNTRY_TYPE_JAPAN 2
|
|
||||||
#define COUNTRY_TYPE_EUROPE 3
|
|
||||||
#define COUNTRY_TYPE_OTHER 4
|
|
||||||
|
|
||||||
typedef struct _CUSTOM_LAUNCH_DATA
|
|
||||||
{
|
|
||||||
DWORD magic ; //populate this with CUSTOM_LAUNCH_MAGIC so we know we are using this special structure
|
|
||||||
char szFilename[300] ; //this is the path to the game to load upon startup
|
|
||||||
char szLaunchXBEOnExit[100] ; //this is the XBE name that should be launched when exiting the emu ( "FILE.XBE" )
|
|
||||||
char szRemap_D_As[350] ; //this is what D drive should be mapped to in order to launch the XBE specified in szLaunchXBEOnExit ( "\\Device\\Harddisk0\\Partition1\\GAMES" )
|
|
||||||
BYTE country ; //country code to use
|
|
||||||
BYTE launchInsertedMedia ; //should we auto-run the inserted CD/DVD ?
|
|
||||||
BYTE executionType ; //generic variable that determines how the emulator is run - for example, if you wish to run FMSXBOX as MSX1 or MSX2 or MSX2+
|
|
||||||
char reserved[MAX_LAUNCH_DATA_SIZE-757] ; //MAX_LAUNCH_DATA_SIZE is 3KB
|
|
||||||
|
|
||||||
} CUSTOM_LAUNCH_DATA, *PCUSTOM_LAUNCH_DATA;
|
|
||||||
|
|
||||||
extern CUSTOM_LAUNCH_DATA g_launchData ;
|
|
||||||
extern int g_autoLaunchGame ;
|
|
||||||
extern int g_launchReturnXBE ;
|
|
||||||
|
|
||||||
|
|
||||||
int XGetCustomLaunchData() ;
|
|
||||||
void XReturnToLaunchingXBE( );
|
|
||||||
|
|
||||||
#endif
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -5,16 +5,7 @@
|
|||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
#if defined(_XBOX)
|
#if defined(_WINDOWS)
|
||||||
void noise_get_heavy(void (*func) (void *, int))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void noise_get_light(void (*func) (void *, int))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(_WINDOWS)
|
|
||||||
#define _WIN32_WINNT 0x0400 // VC6 header needs this defined.
|
#define _WIN32_WINNT 0x0400 // VC6 header needs this defined.
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <wincrypt.h>
|
#include <wincrypt.h>
|
||||||
|
|||||||
+6
-41
@@ -10,9 +10,9 @@
|
|||||||
|
|
||||||
#include "ezsockets.h"
|
#include "ezsockets.h"
|
||||||
|
|
||||||
#if defined(_MSC_VER) && !defined(_XBOX) // We need the WinSock32 Library on Windows
|
#if defined(_MSC_VER) // We need the WinSock32 Library on Windows
|
||||||
#pragma comment(lib,"wsock32.lib")
|
#pragma comment(lib,"wsock32.lib")
|
||||||
#elif !defined(__MINGW32__) && !defined(_XBOX)
|
#elif !defined(__MINGW32__)
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -38,7 +38,7 @@ EzSockets::EzSockets()
|
|||||||
MAXCON = 5;
|
MAXCON = 5;
|
||||||
memset (&addr,0,sizeof(addr)); //Clear the sockaddr_in structure
|
memset (&addr,0,sizeof(addr)); //Clear the sockaddr_in structure
|
||||||
|
|
||||||
#if defined(_WINDOWS) || defined(_XBOX) // Windows REQUIRES WinSock Startup
|
#if defined(_WINDOWS) // Windows REQUIRES WinSock Startup
|
||||||
WSAStartup( MAKEWORD(1,1), &wsda );
|
WSAStartup( MAKEWORD(1,1), &wsda );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -61,11 +61,7 @@ EzSockets::~EzSockets()
|
|||||||
//Check to see if the socket has been created
|
//Check to see if the socket has been created
|
||||||
bool EzSockets::check()
|
bool EzSockets::check()
|
||||||
{
|
{
|
||||||
#if !defined(XBOX)
|
|
||||||
return sock > SOCKET_NONE;
|
return sock > SOCKET_NONE;
|
||||||
#else
|
|
||||||
return sock != INVALID_SOCKET;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EzSockets::create()
|
bool EzSockets::create()
|
||||||
@@ -82,13 +78,7 @@ bool EzSockets::create(int Protocol)
|
|||||||
case IPPROTO_UDP:
|
case IPPROTO_UDP:
|
||||||
return create(IPPROTO_UDP, SOCK_DGRAM);
|
return create(IPPROTO_UDP, SOCK_DGRAM);
|
||||||
default:
|
default:
|
||||||
/* XBOX does not support raw sockets. So, since there's no need,
|
|
||||||
we aren't going to allow it on the XBOX. */
|
|
||||||
#if defined(_XBOX)
|
|
||||||
return false;
|
|
||||||
#else
|
|
||||||
return create(Protocol, SOCK_RAW);
|
return create(Protocol, SOCK_RAW);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,14 +87,9 @@ bool EzSockets::create(int Protocol, int Type)
|
|||||||
state = skDISCONNECTED;
|
state = skDISCONNECTED;
|
||||||
sock = socket(AF_INET, Type, Protocol);
|
sock = socket(AF_INET, Type, Protocol);
|
||||||
lastCode = sock;
|
lastCode = sock;
|
||||||
#if !defined(XBOX)
|
return sock > SOCKET_NONE; // Socket must be Greater than 0
|
||||||
return sock > SOCKET_NONE; //Socket must be Greater than 0
|
|
||||||
#else
|
|
||||||
return sock != INVALID_SOCKET;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool EzSockets::bind(unsigned short port)
|
bool EzSockets::bind(unsigned short port)
|
||||||
{
|
{
|
||||||
if(!check())
|
if(!check())
|
||||||
@@ -184,32 +169,12 @@ bool EzSockets::connect(const std::string& host, unsigned short port)
|
|||||||
if(!check())
|
if(!check())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#if defined(_XBOX)
|
|
||||||
if(!isdigit(host[0])) // don't do a DNS lookup for an IP address
|
|
||||||
{
|
|
||||||
XNDNS *pxndns = NULL;
|
|
||||||
XNetDnsLookup(host.c_str(), NULL, &pxndns);
|
|
||||||
while (pxndns->iStatus == WSAEINPROGRESS)
|
|
||||||
{
|
|
||||||
// Do something else while lookup is in progress
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pxndns->iStatus == 0)
|
|
||||||
memcpy(&addr.sin_addr, &pxndns->aina[0], sizeof(struct in_addr));
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
|
|
||||||
XNetDnsRelease(pxndns);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
addr.sin_addr.s_addr = inet_addr(host.c_str());
|
|
||||||
#else
|
|
||||||
struct hostent* phe;
|
struct hostent* phe;
|
||||||
phe = gethostbyname(host.c_str());
|
phe = gethostbyname(host.c_str());
|
||||||
if (phe == NULL)
|
if (phe == NULL)
|
||||||
return false;
|
return false;
|
||||||
memcpy(&addr.sin_addr, phe->h_addr, sizeof(struct in_addr));
|
memcpy(&addr.sin_addr, phe->h_addr, sizeof(struct in_addr));
|
||||||
#endif
|
|
||||||
addr.sin_family = AF_INET;
|
addr.sin_family = AF_INET;
|
||||||
addr.sin_port = htons(port);
|
addr.sin_port = htons(port);
|
||||||
|
|
||||||
@@ -266,7 +231,7 @@ void EzSockets::update()
|
|||||||
|
|
||||||
unsigned long EzSockets::LongFromAddrIn( const sockaddr_in & s )
|
unsigned long EzSockets::LongFromAddrIn( const sockaddr_in & s )
|
||||||
{
|
{
|
||||||
#if defined(_XBOX) || defined(_WINDOWS)
|
#if defined(_WINDOWS)
|
||||||
return ntohl(s.sin_addr.S_un.S_addr);
|
return ntohl(s.sin_addr.S_un.S_addr);
|
||||||
#else
|
#else
|
||||||
return ntohl(s.sin_addr.s_addr);
|
return ntohl(s.sin_addr.s_addr);
|
||||||
|
|||||||
+3
-11
@@ -19,15 +19,7 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#if defined(_XBOX)
|
#if defined(_WINDOWS)
|
||||||
/*
|
|
||||||
* Summary : WinsockX is bad, XTL is good.
|
|
||||||
* Explained : WinsockX may rely on some declares that are present in XTL.
|
|
||||||
* Also, using XTL includes some files maybe needed for other operations
|
|
||||||
* on Xbox.
|
|
||||||
*/
|
|
||||||
#include <xtl.h>
|
|
||||||
#elif defined(_WINDOWS)
|
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#else
|
#else
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
@@ -132,8 +124,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Only necessary for Windows and Xbox
|
// Only necessary for Windows
|
||||||
#if defined(_WINDOWS) || defined(_XBOX)
|
#if defined(_WINDOWS)
|
||||||
WSADATA wsda;
|
WSADATA wsda;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
# include "archutils/Darwin/Crash.h"
|
# include "archutils/Darwin/Crash.h"
|
||||||
using CrashHandler::IsDebuggerPresent;
|
using CrashHandler::IsDebuggerPresent;
|
||||||
using CrashHandler::DebugBreak;
|
using CrashHandler::DebugBreak;
|
||||||
#elif defined(XBOX)
|
|
||||||
#else
|
#else
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ typedef unsigned int JDIMENSION;
|
|||||||
/* a function referenced thru EXTERNs: */
|
/* a function referenced thru EXTERNs: */
|
||||||
#define GLOBAL(type) type
|
#define GLOBAL(type) type
|
||||||
/* a reference to a GLOBAL function: */
|
/* a reference to a GLOBAL function: */
|
||||||
#if defined(WIN32) && !defined(XBOX)
|
#if defined(WIN32)
|
||||||
# ifdef BUILDING_JPEG_DLL
|
# ifdef BUILDING_JPEG_DLL
|
||||||
# define DLLIMPORT __declspec (dllexport)
|
# define DLLIMPORT __declspec (dllexport)
|
||||||
# else
|
# else
|
||||||
|
|||||||
@@ -700,11 +700,10 @@ union luai_Cast { double l_d; long l_l; };
|
|||||||
#define LUA_DL_DLOPEN
|
#define LUA_DL_DLOPEN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(LUA_WIN) && !defined(XBOX)
|
#if defined(LUA_WIN)
|
||||||
#define LUA_DL_DLL
|
#define LUA_DL_DLL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State
|
@@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State
|
||||||
@* (the data goes just *before* the lua_State pointer).
|
@* (the data goes just *before* the lua_State pointer).
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
Microsoft Visual Studio Solution File, Format Version 8.00
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StepMania", "StepManiaXbox-2003.vcproj", "{670745A6-106B-420D-A2A9-D4F89A23986E}"
|
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
{15A6313B-3206-4847-87A2-62255F0B3837} = {15A6313B-3206-4847-87A2-62255F0B3837}
|
|
||||||
{00C33C79-1140-47B0-838B-109A61950513} = {00C33C79-1140-47B0-838B-109A61950513}
|
|
||||||
{CA22B79A-E8A9-4BFB-A297-42231F2213F2} = {CA22B79A-E8A9-4BFB-A297-42231F2213F2}
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xboxmad", "mad-0.15.1b\xboxmad\xboxmad-2003.vcproj", "{CA22B79A-E8A9-4BFB-A297-42231F2213F2}"
|
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libtomcrypt", "libtomcrypt\libtomcryptXbox-net2003.vcproj", "{15A6313B-3206-4847-87A2-62255F0B3837}"
|
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
{00C33C79-1140-47B0-838B-109A61950513} = {00C33C79-1140-47B0-838B-109A61950513}
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libtommath", "libtommath\libtommathXbox-net2003.vcproj", "{00C33C79-1140-47B0-838B-109A61950513}"
|
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(DPCodeReviewSolutionGUID) = preSolution
|
|
||||||
DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000}
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionConfiguration) = preSolution
|
|
||||||
Debug Xbox = Debug Xbox
|
|
||||||
Release Xbox = Release Xbox
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfiguration) = postSolution
|
|
||||||
{670745A6-106B-420D-A2A9-D4F89A23986E}.Debug Xbox.ActiveCfg = Debug|Xbox
|
|
||||||
{670745A6-106B-420D-A2A9-D4F89A23986E}.Debug Xbox.Build.0 = Debug|Xbox
|
|
||||||
{670745A6-106B-420D-A2A9-D4F89A23986E}.Release Xbox.ActiveCfg = Release|Xbox
|
|
||||||
{670745A6-106B-420D-A2A9-D4F89A23986E}.Release Xbox.Build.0 = Release|Xbox
|
|
||||||
{CA22B79A-E8A9-4BFB-A297-42231F2213F2}.Debug Xbox.ActiveCfg = Debug|Xbox
|
|
||||||
{CA22B79A-E8A9-4BFB-A297-42231F2213F2}.Debug Xbox.Build.0 = Debug|Xbox
|
|
||||||
{CA22B79A-E8A9-4BFB-A297-42231F2213F2}.Release Xbox.ActiveCfg = Release|Xbox
|
|
||||||
{CA22B79A-E8A9-4BFB-A297-42231F2213F2}.Release Xbox.Build.0 = Release|Xbox
|
|
||||||
{15A6313B-3206-4847-87A2-62255F0B3837}.Debug Xbox.ActiveCfg = Debug|Xbox
|
|
||||||
{15A6313B-3206-4847-87A2-62255F0B3837}.Debug Xbox.Build.0 = Debug|Xbox
|
|
||||||
{15A6313B-3206-4847-87A2-62255F0B3837}.Release Xbox.ActiveCfg = Release|Xbox
|
|
||||||
{15A6313B-3206-4847-87A2-62255F0B3837}.Release Xbox.Build.0 = Release|Xbox
|
|
||||||
{00C33C79-1140-47B0-838B-109A61950513}.Debug Xbox.ActiveCfg = Debug|Xbox
|
|
||||||
{00C33C79-1140-47B0-838B-109A61950513}.Debug Xbox.Build.0 = Debug|Xbox
|
|
||||||
{00C33C79-1140-47B0-838B-109A61950513}.Release Xbox.ActiveCfg = Release|Xbox
|
|
||||||
{00C33C79-1140-47B0-838B-109A61950513}.Release Xbox.Build.0 = Release|Xbox
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
|
||||||
DPBuild = 5
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
||||||
Reference in New Issue
Block a user