mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 03:32:46 +00:00
Merge branch 'master' of https://github.com/Themaister/RetroArch
This commit is contained in:
commit
8da3f8c387
@ -1,163 +0,0 @@
|
|||||||
/* RetroArch - A frontend for libretro.
|
|
||||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
|
||||||
* Copyright (C) 2011-2012 - Daniel De Matteis
|
|
||||||
*
|
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
||||||
* of the GNU General Public License as published by the Free Software Found-
|
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <xgraphics.h>
|
|
||||||
#include "xdk360_video_resources.h"
|
|
||||||
|
|
||||||
struct XPR_HEADER
|
|
||||||
{
|
|
||||||
unsigned long dwMagic;
|
|
||||||
unsigned long dwHeaderSize;
|
|
||||||
unsigned long dwDataSize;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define XPR2_MAGIC_VALUE (0x58505232)
|
|
||||||
|
|
||||||
PackedResource::PackedResource()
|
|
||||||
{
|
|
||||||
m_pSysMemData = NULL;
|
|
||||||
m_dwSysMemDataSize = 0L;
|
|
||||||
m_pVidMemData = NULL;
|
|
||||||
m_dwVidMemDataSize = 0L;
|
|
||||||
m_pResourceTags = NULL;
|
|
||||||
m_dwNumResourceTags = 0L;
|
|
||||||
m_bInitialized = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
PackedResource::~PackedResource()
|
|
||||||
{
|
|
||||||
Destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
void * PackedResource::GetData( const char * strName ) const
|
|
||||||
{
|
|
||||||
if( m_pResourceTags == NULL || strName == NULL )
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
for( unsigned long i = 0; i < m_dwNumResourceTags; i++ )
|
|
||||||
{ if( !_stricmp( strName, m_pResourceTags[i].strName ) )
|
|
||||||
return &m_pSysMemData[m_pResourceTags[i].dwOffset];
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT PackedResource::Create( const char * strFilename )
|
|
||||||
{
|
|
||||||
unsigned long dwNumBytesRead;
|
|
||||||
void * hFile = CreateFile( strFilename, GENERIC_READ, FILE_SHARE_READ, NULL,
|
|
||||||
OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL );
|
|
||||||
|
|
||||||
if( hFile == INVALID_HANDLE_VALUE )
|
|
||||||
{
|
|
||||||
RARCH_ERR( "File <%s> not found.\n", strFilename );
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read in and verify the XPR magic header
|
|
||||||
XPR_HEADER xprh;
|
|
||||||
if( !ReadFile( hFile, &xprh, sizeof( XPR_HEADER ), &dwNumBytesRead, NULL ) )
|
|
||||||
{
|
|
||||||
RARCH_ERR( "Error reading XPR header in file <%s>.\n", strFilename );
|
|
||||||
CloseHandle( hFile );
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( xprh.dwMagic != XPR2_MAGIC_VALUE )
|
|
||||||
{
|
|
||||||
RARCH_ERR( "Invalid Xbox Packed Resource (.xpr) file: Magic = 0x%08lx.\n", xprh.dwMagic );
|
|
||||||
CloseHandle( hFile );
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compute memory requirements
|
|
||||||
m_dwSysMemDataSize = xprh.dwHeaderSize;
|
|
||||||
m_dwVidMemDataSize = xprh.dwDataSize;
|
|
||||||
|
|
||||||
// Allocate memory
|
|
||||||
m_pSysMemData = (unsigned char*)malloc(m_dwSysMemDataSize);
|
|
||||||
if( m_pSysMemData == NULL )
|
|
||||||
{
|
|
||||||
RARCH_ERR( "Could not allocate system memory.\n" );
|
|
||||||
m_dwSysMemDataSize = 0;
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
m_pVidMemData = ( unsigned char* )XMemAlloc( m_dwVidMemDataSize, MAKE_XALLOC_ATTRIBUTES( 0, 0, 0, 0, eXALLOCAllocatorId_GameMax,
|
|
||||||
XALLOC_PHYSICAL_ALIGNMENT_4K, XALLOC_MEMPROTECT_WRITECOMBINE, 0, XALLOC_MEMTYPE_PHYSICAL ) );
|
|
||||||
|
|
||||||
if( m_pVidMemData == NULL )
|
|
||||||
{
|
|
||||||
RARCH_ERR( "Could not allocate physical memory.\n" );
|
|
||||||
m_dwSysMemDataSize = 0;
|
|
||||||
m_dwVidMemDataSize = 0;
|
|
||||||
free(m_pSysMemData);
|
|
||||||
m_pSysMemData = NULL;
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read in the data from the file
|
|
||||||
if( !ReadFile( hFile, m_pSysMemData, m_dwSysMemDataSize, &dwNumBytesRead, NULL ) ||
|
|
||||||
!ReadFile( hFile, m_pVidMemData, m_dwVidMemDataSize, &dwNumBytesRead, NULL ) )
|
|
||||||
{
|
|
||||||
RARCH_ERR( "Unable to read Xbox Packed Resource (.xpr) file.\n" );
|
|
||||||
CloseHandle( hFile );
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Done with the file
|
|
||||||
CloseHandle( hFile );
|
|
||||||
|
|
||||||
// Extract resource table from the header data
|
|
||||||
m_dwNumResourceTags = *( unsigned long * )( m_pSysMemData + 0 );
|
|
||||||
m_pResourceTags = ( RESOURCE* )( m_pSysMemData + 4 );
|
|
||||||
|
|
||||||
// Patch up the resources
|
|
||||||
for( unsigned long i = 0; i < m_dwNumResourceTags; i++ )
|
|
||||||
{
|
|
||||||
m_pResourceTags[i].strName = ( char * )( m_pSysMemData + ( unsigned long )m_pResourceTags[i].strName );
|
|
||||||
|
|
||||||
// Fixup the texture memory
|
|
||||||
if( ( m_pResourceTags[i].dwType & 0xffff0000 ) == ( RESOURCETYPE_TEXTURE & 0xffff0000 ) )
|
|
||||||
{
|
|
||||||
D3DTexture* pTexture = ( D3DTexture* )&m_pSysMemData[m_pResourceTags[i].dwOffset];
|
|
||||||
// Adjust Base address according to where memory was allocated
|
|
||||||
XGOffsetBaseTextureAddress( pTexture, m_pVidMemData, m_pVidMemData );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_bInitialized = TRUE;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PackedResource::Destroy()
|
|
||||||
{
|
|
||||||
free(m_pSysMemData);
|
|
||||||
m_pSysMemData = NULL;
|
|
||||||
m_dwSysMemDataSize = 0L;
|
|
||||||
|
|
||||||
if( m_pVidMemData != NULL )
|
|
||||||
XMemFree( m_pVidMemData, MAKE_XALLOC_ATTRIBUTES( 0, 0, 0, 0, eXALLOCAllocatorId_GameMax,
|
|
||||||
0, 0, 0, XALLOC_MEMTYPE_PHYSICAL ) );
|
|
||||||
|
|
||||||
m_pVidMemData = NULL;
|
|
||||||
m_dwVidMemDataSize = 0L;
|
|
||||||
|
|
||||||
m_pResourceTags = NULL;
|
|
||||||
m_dwNumResourceTags = 0L;
|
|
||||||
|
|
||||||
m_bInitialized = FALSE;
|
|
||||||
}
|
|
@ -1,86 +0,0 @@
|
|||||||
/* RetroArch - A frontend for libretro.
|
|
||||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
|
||||||
* Copyright (C) 2011-2012 - Daniel De Matteis
|
|
||||||
*
|
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
||||||
* of the GNU General Public License as published by the Free Software Found-
|
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef RARCH_360_RESOURCES_H
|
|
||||||
#define RARCH_360_RESOURCES_H
|
|
||||||
|
|
||||||
struct RESOURCE
|
|
||||||
{
|
|
||||||
unsigned long dwType;
|
|
||||||
unsigned long dwOffset;
|
|
||||||
unsigned long dwSize;
|
|
||||||
char * strName;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Resource types
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
RESOURCETYPE_USERDATA = ( ( 'U' << 24 ) | ( 'S' << 16 ) | ( 'E' << 8 ) | ( 'R' ) ),
|
|
||||||
RESOURCETYPE_TEXTURE = ( ( 'T' << 24 ) | ( 'X' << 16 ) | ( '2' << 8 ) | ( 'D' ) ),
|
|
||||||
RESOURCETYPE_CUBEMAP = ( ( 'T' << 24 ) | ( 'X' << 16 ) | ( 'C' << 8 ) | ( 'M' ) ),
|
|
||||||
RESOURCETYPE_VOLUMETEXTURE = ( ( 'T' << 24 ) | ( 'X' << 16 ) | ( '3' << 8 ) | ( 'D' ) ),
|
|
||||||
RESOURCETYPE_VERTEXBUFFER = ( ( 'V' << 24 ) | ( 'B' << 16 ) | ( 'U' << 8 ) | ( 'F' ) ),
|
|
||||||
RESOURCETYPE_INDEXBUFFER = ( ( 'I' << 24 ) | ( 'B' << 16 ) | ( 'U' << 8 ) | ( 'F' ) ),
|
|
||||||
RESOURCETYPE_EOF = 0xffffffff
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class PackedResource
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
unsigned char * m_pSysMemData; // Alloc'ed memory for resource headers etc.
|
|
||||||
unsigned char * m_pVidMemData; // Alloc'ed memory for resource data, etc.
|
|
||||||
unsigned long m_dwSysMemDataSize;
|
|
||||||
unsigned long m_dwVidMemDataSize;
|
|
||||||
unsigned long m_dwNumResourceTags; // Number of resource tags
|
|
||||||
RESOURCE* m_pResourceTags; // Tags to associate names with the resources
|
|
||||||
public:
|
|
||||||
int m_bInitialized; // Resource is fully initialized
|
|
||||||
HRESULT Create( const char * strFilename );
|
|
||||||
void Destroy();
|
|
||||||
|
|
||||||
void * GetData( unsigned long dwOffset ) const
|
|
||||||
{
|
|
||||||
return &m_pSysMemData[dwOffset];
|
|
||||||
}
|
|
||||||
|
|
||||||
D3DResource* GetResource( unsigned long dwOffset ) const
|
|
||||||
{
|
|
||||||
return (( D3DResource* )GetData( dwOffset ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
D3DTexture* GetTexture( unsigned long dwOffset ) const
|
|
||||||
{
|
|
||||||
return ( D3DTexture* )GetResource( dwOffset );
|
|
||||||
}
|
|
||||||
|
|
||||||
void * GetData( const char * strName ) const;
|
|
||||||
|
|
||||||
D3DResource* GetResource( const char * strName ) const
|
|
||||||
{
|
|
||||||
return ( ( D3DResource* )GetData( strName ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
D3DTexture* GetTexture( const char * strName ) const
|
|
||||||
{
|
|
||||||
return ( D3DTexture* )GetResource( strName );
|
|
||||||
}
|
|
||||||
|
|
||||||
PackedResource();
|
|
||||||
~PackedResource();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -38,7 +38,7 @@
|
|||||||
#include "../gfx/fonts/xdk360_fonts.h"
|
#include "../gfx/fonts/xdk360_fonts.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "xdk360_video_resources.h"
|
#include "../xdk/xdk_resources.h"
|
||||||
|
|
||||||
extern video_console_t video_console;
|
extern video_console_t video_console;
|
||||||
extern xdk360_video_font_t m_Font;
|
extern xdk360_video_font_t m_Font;
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#define _XDK360_VIDEO_H
|
#define _XDK360_VIDEO_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include "../xdk/xdk_defines.h"
|
||||||
|
|
||||||
#define DFONT_MAX 4096
|
#define DFONT_MAX 4096
|
||||||
#define PRIM_FVF (D3DFVF_XYZRHW | D3DFVF_TEX1)
|
#define PRIM_FVF (D3DFVF_XYZRHW | D3DFVF_TEX1)
|
||||||
@ -41,19 +42,6 @@ typedef struct DrawVerticeFormats
|
|||||||
float u, v;
|
float u, v;
|
||||||
} DrawVerticeFormats;
|
} DrawVerticeFormats;
|
||||||
|
|
||||||
/* Direct3D 9 */
|
|
||||||
#define LPDIRECT3D_PTR LPDIRECT3D9
|
|
||||||
#define LPDIRECT3DDEVICE_PTR LPDIRECT3DDEVICE9
|
|
||||||
#define LPDIRECT3DTEXTURE_PTR LPDIRECT3DTEXTURE9
|
|
||||||
#define LPDIRECT3DSURFACE_PTR LPDIRECT3DSURFACE9
|
|
||||||
#define LPDIRECT3DVERTEXBUFFER_PTR LPDIRECT3DVERTEXBUFFER9
|
|
||||||
|
|
||||||
#define D3DVIEWPORT D3DVIEWPORT9
|
|
||||||
#define D3DVERTEXELEMENT D3DVERTEXELEMENT9
|
|
||||||
|
|
||||||
#define direct3d_create_ctx Direct3DCreate9
|
|
||||||
#define IDirect3DVertexDeclaration IDirect3DVertexDeclaration9
|
|
||||||
|
|
||||||
typedef struct xdk_d3d_video
|
typedef struct xdk_d3d_video
|
||||||
{
|
{
|
||||||
bool block_swap;
|
bool block_swap;
|
||||||
@ -64,16 +52,16 @@ typedef struct xdk_d3d_video
|
|||||||
unsigned frame_count;
|
unsigned frame_count;
|
||||||
unsigned last_width;
|
unsigned last_width;
|
||||||
unsigned last_height;
|
unsigned last_height;
|
||||||
LPDIRECT3D_PTR d3d_device;
|
LPDIRECT3D d3d_device;
|
||||||
LPDIRECT3DDEVICE_PTR d3d_render_device;
|
LPDIRECT3DDEVICE d3d_render_device;
|
||||||
LPDIRECT3DVERTEXBUFFER_PTR vertex_buf;
|
LPDIRECT3DVERTEXBUFFER vertex_buf;
|
||||||
LPDIRECT3DTEXTURE_PTR lpTexture;
|
LPDIRECT3DTEXTURE lpTexture;
|
||||||
D3DTexture lpTexture_ot_as16srgb;
|
D3DTexture lpTexture_ot_as16srgb;
|
||||||
LPDIRECT3DTEXTURE_PTR lpTexture_ot;
|
LPDIRECT3DTEXTURE lpTexture_ot;
|
||||||
IDirect3DVertexDeclaration9* v_decl;
|
IDirect3DVertexDeclaration9* v_decl;
|
||||||
XVIDEO_MODE video_mode;
|
XVIDEO_MODE video_mode;
|
||||||
D3DPRESENT_PARAMETERS d3dpp;
|
D3DPRESENT_PARAMETERS d3dpp;
|
||||||
LPDIRECT3DSURFACE_PTR lpSurface;
|
LPDIRECT3DSURFACE lpSurface;
|
||||||
} xdk_d3d_video_t;
|
} xdk_d3d_video_t;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#include "../driver.h"
|
#include "../driver.h"
|
||||||
#include "../general.h"
|
#include "../general.h"
|
||||||
#include "../libretro.h"
|
#include "../libretro.h"
|
||||||
#include "rarch_xinput2.h"
|
#include "xinput_360_input.h"
|
||||||
|
|
||||||
static uint64_t state[4];
|
static uint64_t state[4];
|
||||||
static unsigned pads_connected;
|
static unsigned pads_connected;
|
@ -14,10 +14,8 @@
|
|||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __RARCH_XINPUT2_H
|
#ifndef _XDK360_XINPUT2_H
|
||||||
#define __RARCH_XINPUT2_H
|
#define _XDK360_XINPUT2_H
|
||||||
|
|
||||||
#ifndef _XBOX1
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
XINPUT_GAMEPAD_LSTICK_LEFT_MASK = 1 << 16,
|
XINPUT_GAMEPAD_LSTICK_LEFT_MASK = 1 << 16,
|
||||||
@ -31,7 +29,7 @@ enum {
|
|||||||
XINPUT_GAMEPAD_LEFT_TRIGGER = 1 << 24,
|
XINPUT_GAMEPAD_LEFT_TRIGGER = 1 << 24,
|
||||||
XINPUT_GAMEPAD_RIGHT_TRIGGER = 1 << 25
|
XINPUT_GAMEPAD_RIGHT_TRIGGER = 1 << 25
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
#define DEADZONE (16000)
|
#define DEADZONE (16000)
|
||||||
|
|
||||||
#ifdef _XBOX
|
#ifdef _XBOX
|
@ -92,8 +92,6 @@ VIDEO DRIVER
|
|||||||
#include "../../gfx/gl.c"
|
#include "../../gfx/gl.c"
|
||||||
#elif defined(HAVE_OPENGLES20)
|
#elif defined(HAVE_OPENGLES20)
|
||||||
#include "../../gfx/gles.c"
|
#include "../../gfx/gles.c"
|
||||||
#elif defined(_XBOX360)
|
|
||||||
#include "../../360/xdk360_video_resources.cpp"
|
|
||||||
#elif defined(GEKKO)
|
#elif defined(GEKKO)
|
||||||
#include "../../wii/video.c"
|
#include "../../wii/video.c"
|
||||||
#endif
|
#endif
|
||||||
@ -101,6 +99,7 @@ VIDEO DRIVER
|
|||||||
#include "../../gfx/gfx_common.c"
|
#include "../../gfx/gfx_common.c"
|
||||||
|
|
||||||
#ifdef _XBOX
|
#ifdef _XBOX
|
||||||
|
#include "../../xdk/xdk_resources.cpp"
|
||||||
#if defined(HAVE_D3D9)
|
#if defined(HAVE_D3D9)
|
||||||
#include "../../360/xdk_d3d9.cpp"
|
#include "../../360/xdk_d3d9.cpp"
|
||||||
#elif defined(HAVE_D3D8)
|
#elif defined(HAVE_D3D8)
|
||||||
@ -133,7 +132,7 @@ INPUT
|
|||||||
#if defined(HAVE_XINPUT_XBOX1)
|
#if defined(HAVE_XINPUT_XBOX1)
|
||||||
#include "../../xbox1/xinput_xbox_input.c"
|
#include "../../xbox1/xinput_xbox_input.c"
|
||||||
#elif defined(HAVE_XINPUT2)
|
#elif defined(HAVE_XINPUT2)
|
||||||
#include "../../input/xinput2_input.c"
|
#include "../../360/xinput_360_input.c"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -231,7 +230,7 @@ REWIND
|
|||||||
MAIN
|
MAIN
|
||||||
============================================================ */
|
============================================================ */
|
||||||
#if defined(_XBOX)
|
#if defined(_XBOX)
|
||||||
#include "../../360/frontend-xdk/main.c"
|
#include "../../xdk/frontend/main.c"
|
||||||
#elif defined(GEKKO)
|
#elif defined(GEKKO)
|
||||||
#include "../../wii/frontend/main.c"
|
#include "../../wii/frontend/main.c"
|
||||||
#endif
|
#endif
|
||||||
|
@ -41,8 +41,8 @@ enum
|
|||||||
DPAD_EMULATION_RSTICK
|
DPAD_EMULATION_RSTICK
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef _XBOX
|
#ifdef _XBOX360
|
||||||
#include "../input/rarch_xinput2.h"
|
#include "../360/xinput_360_input.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__CELLOS_LV2__)
|
#if defined(__CELLOS_LV2__)
|
||||||
|
@ -366,7 +366,7 @@ void d3d9_deinit_font(void)
|
|||||||
s_FontLocals.m_pFontVertexShader = NULL;
|
s_FontLocals.m_pFontVertexShader = NULL;
|
||||||
if( ( s_FontLocals.m_pFontVertexDecl != NULL ) && ( s_FontLocals.m_pFontVertexDecl->Release() == 0 ) )
|
if( ( s_FontLocals.m_pFontVertexDecl != NULL ) && ( s_FontLocals.m_pFontVertexDecl->Release() == 0 ) )
|
||||||
s_FontLocals.m_pFontVertexDecl = NULL;
|
s_FontLocals.m_pFontVertexDecl = NULL;
|
||||||
if( m_xprResource.m_bInitialized)
|
if( m_xprResource.Initialized())
|
||||||
m_xprResource.Destroy();
|
m_xprResource.Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
#ifndef RARCH_360_FONTS_H
|
#ifndef RARCH_360_FONTS_H
|
||||||
#define RARCH_360_FONTS_H
|
#define RARCH_360_FONTS_H
|
||||||
|
|
||||||
#include "xdk360_video_resources.h"
|
#include "../../xdk/xdk_resources.h"
|
||||||
|
|
||||||
#define PAGE_UP (255)
|
#define PAGE_UP (255)
|
||||||
#define PAGE_DOWN (-255)
|
#define PAGE_DOWN (-255)
|
||||||
|
@ -26,7 +26,11 @@
|
|||||||
static int gettimeofday(struct timeval *val, void *dummy)
|
static int gettimeofday(struct timeval *val, void *dummy)
|
||||||
{
|
{
|
||||||
(void)dummy;
|
(void)dummy;
|
||||||
|
#ifdef _XBOX360
|
||||||
|
DWORD msec = GetTickCount();
|
||||||
|
#else
|
||||||
DWORD msec = timeGetTime();
|
DWORD msec = timeGetTime();
|
||||||
|
#endif
|
||||||
uint64_t usec = msec * 1000;
|
uint64_t usec = msec * 1000;
|
||||||
val->tv_sec = usec / 1000000;
|
val->tv_sec = usec / 1000000;
|
||||||
val->tv_usec = usec % 1000000;
|
val->tv_usec = usec % 1000000;
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <xfont.h>
|
#include <xfont.h>
|
||||||
|
|
||||||
|
#include "../xdk/xdk_defines.h"
|
||||||
|
|
||||||
#define SHOW_DEBUG_INFO
|
#define SHOW_DEBUG_INFO
|
||||||
|
|
||||||
#define DFONT_MAX 4096
|
#define DFONT_MAX 4096
|
||||||
@ -45,27 +47,6 @@ typedef struct DrawVerticeFormats
|
|||||||
float u, v;
|
float u, v;
|
||||||
} DrawVerticeFormats;
|
} DrawVerticeFormats;
|
||||||
|
|
||||||
/* Direct3D 8 */
|
|
||||||
#define LPDIRECT3D_PTR LPDIRECT3D8
|
|
||||||
#define LPDIRECT3DDEVICE_PTR LPDIRECT3DDEVICE8
|
|
||||||
#define LPDIRECT3DTEXTURE_PTR LPDIRECT3DTEXTURE8
|
|
||||||
#define LPDIRECT3DSURFACE_PTR LPDIRECT3DSURFACE8
|
|
||||||
#define LPDIRECT3DVERTEXBUFFER_PTR LPDIRECT3DVERTEXBUFFER8
|
|
||||||
|
|
||||||
#define D3DVIEWPORT D3DVIEWPORT8
|
|
||||||
#define D3DVERTEXELEMENT D3DVERTEXELEMENT8
|
|
||||||
|
|
||||||
#define direct3d_create_ctx Direct3DCreate8
|
|
||||||
#define IDirect3DVertexBuffer IDirect3DVertexBuffer8
|
|
||||||
|
|
||||||
#define SetSamplerState SetTextureStageState
|
|
||||||
#define D3DLOCK_NOSYSLOCK (0)
|
|
||||||
|
|
||||||
#define D3DSAMP_ADDRESSU D3DTSS_ADDRESSU
|
|
||||||
#define D3DSAMP_ADDRESSV D3DTSS_ADDRESSV
|
|
||||||
#define D3DSAMP_MAGFILTER D3DTSS_MAGFILTER
|
|
||||||
#define D3DSAMP_MINFILTER D3DTSS_MINFILTER
|
|
||||||
|
|
||||||
typedef struct xdk_d3d_video
|
typedef struct xdk_d3d_video
|
||||||
{
|
{
|
||||||
bool block_swap;
|
bool block_swap;
|
||||||
@ -76,10 +57,10 @@ typedef struct xdk_d3d_video
|
|||||||
unsigned frame_count;
|
unsigned frame_count;
|
||||||
unsigned last_width;
|
unsigned last_width;
|
||||||
unsigned last_height;
|
unsigned last_height;
|
||||||
LPDIRECT3D_PTR d3d_device;
|
LPDIRECT3D d3d_device;
|
||||||
LPDIRECT3DDEVICE_PTR d3d_render_device;
|
LPDIRECT3DDEVICE d3d_render_device;
|
||||||
LPDIRECT3DVERTEXBUFFER_PTR vertex_buf;
|
LPDIRECT3DVERTEXBUFFER vertex_buf;
|
||||||
LPDIRECT3DTEXTURE_PTR lpTexture;
|
LPDIRECT3DTEXTURE lpTexture;
|
||||||
DWORD video_mode;
|
DWORD video_mode;
|
||||||
D3DPRESENT_PARAMETERS d3dpp;
|
D3DPRESENT_PARAMETERS d3dpp;
|
||||||
XFONT *debug_font;
|
XFONT *debug_font;
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include "../driver.h"
|
#include "../driver.h"
|
||||||
#include "../general.h"
|
#include "../general.h"
|
||||||
#include "../libretro.h"
|
#include "../libretro.h"
|
||||||
#include "../input/rarch_xinput2.h"
|
|
||||||
#include "xinput_xbox_input.h"
|
#include "xinput_xbox_input.h"
|
||||||
|
|
||||||
static XINPUT_STATE state[4];
|
static XINPUT_STATE state[4];
|
||||||
@ -34,6 +33,8 @@ bool bInserted[4];
|
|||||||
bool bRemoved[4];
|
bool bRemoved[4];
|
||||||
XINPUT_CAPABILITIES caps[4];
|
XINPUT_CAPABILITIES caps[4];
|
||||||
|
|
||||||
|
#define DEADZONE (16000)
|
||||||
|
|
||||||
static unsigned pads_connected;
|
static unsigned pads_connected;
|
||||||
|
|
||||||
static void xinput_input_poll(void *data)
|
static void xinput_input_poll(void *data)
|
||||||
|
@ -22,17 +22,16 @@
|
|||||||
|
|
||||||
#ifdef _XBOX360
|
#ifdef _XBOX360
|
||||||
#include <xfilecache.h>
|
#include <xfilecache.h>
|
||||||
#include "menu.h"
|
#include "../../360/frontend-xdk/menu.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <xbdm.h>
|
#include <xbdm.h>
|
||||||
#include "../../input/rarch_xinput2.h"
|
|
||||||
|
|
||||||
#ifdef _XBOX
|
#ifdef _XBOX
|
||||||
#if defined(_XBOX1)
|
#if defined(_XBOX1)
|
||||||
#include "../../xbox1/xdk_d3d8.h"
|
#include "../../xbox1/xdk_d3d8.h"
|
||||||
#elif defined(_XBOX360)
|
#elif defined(_XBOX360)
|
||||||
#include "../xdk_d3d9.h"
|
#include "../../360/xdk_d3d9.h"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
65
xdk/xdk_defines.h
Normal file
65
xdk/xdk_defines.h
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/* RetroArch - A frontend for libretro.
|
||||||
|
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||||
|
* Copyright (C) 2011-2012 - Daniel De Matteis
|
||||||
|
*
|
||||||
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||||
|
* of the GNU General Public License as published by the Free Software Found-
|
||||||
|
* ation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _XDK_DEFINES_H
|
||||||
|
#define _XDK_DEFINES_H
|
||||||
|
|
||||||
|
#if defined(_XBOX1)
|
||||||
|
/* XBox 1*/
|
||||||
|
#define LPDIRECT3DRESOURCE LPDIRECT3DRESOURCE8
|
||||||
|
#define LPDIRECT3DTEXTURE LPDIRECT3DTEXTURE8
|
||||||
|
#define LPDIRECT3DCUBETEXTURE LPDIRECT3DCUBETEXTURE8
|
||||||
|
#define LPDIRECT3DVOLUMETEXTURE LPDIRECT3DVOLUMETEXTURE8
|
||||||
|
#define LPDIRECT3DVERTEXBUFFER LPDIRECT3DVERTEXBUFFER8
|
||||||
|
#define LPDIRECT3DRESOURCE LPDIRECT3DRESOURCE8
|
||||||
|
#define LPDIRECT3D LPDIRECT3D8
|
||||||
|
#define LPDIRECT3DDEVICE LPDIRECT3DDEVICE8
|
||||||
|
#define LPDIRECT3DSURFACE LPDIRECT3DSURFACE8
|
||||||
|
|
||||||
|
#define D3DVIEWPORT D3DVIEWPORT8
|
||||||
|
#define D3DVERTEXELEMENT D3DVERTEXELEMENT8
|
||||||
|
|
||||||
|
#define direct3d_create_ctx Direct3DCreate8
|
||||||
|
#define IDirect3DVertexBuffer IDirect3DVertexBuffer8
|
||||||
|
|
||||||
|
#define SetSamplerState SetTextureStageState
|
||||||
|
#define D3DLOCK_NOSYSLOCK (0)
|
||||||
|
|
||||||
|
#define D3DSAMP_ADDRESSU D3DTSS_ADDRESSU
|
||||||
|
#define D3DSAMP_ADDRESSV D3DTSS_ADDRESSV
|
||||||
|
#define D3DSAMP_MAGFILTER D3DTSS_MAGFILTER
|
||||||
|
#define D3DSAMP_MINFILTER D3DTSS_MINFILTER
|
||||||
|
|
||||||
|
#elif defined(_XBOX360)
|
||||||
|
/* XBox 360*/
|
||||||
|
#define LPDIRECT3D LPDIRECT3D9
|
||||||
|
#define LPDIRECT3DDEVICE LPDIRECT3DDEVICE9
|
||||||
|
#define LPDIRECT3DTEXTURE LPDIRECT3DTEXTURE9
|
||||||
|
#define LPDIRECT3DCUBETEXTURE LPDIRECT3DCUBETEXTURE9
|
||||||
|
#define LPDIRECT3DSURFACE LPDIRECT3DSURFACE9
|
||||||
|
#define LPDIRECT3DVOLUMETEXTURE LPDIRECT3DVOLUMETEXTURE9
|
||||||
|
#define LPDIRECT3DVERTEXBUFFER LPDIRECT3DVERTEXBUFFER9
|
||||||
|
#define LPDIRECT3DRESOURCE LPDIRECT3DRESOURCE9
|
||||||
|
|
||||||
|
#define D3DVIEWPORT D3DVIEWPORT9
|
||||||
|
#define D3DVERTEXELEMENT D3DVERTEXELEMENT9
|
||||||
|
|
||||||
|
#define direct3d_create_ctx Direct3DCreate9
|
||||||
|
#define IDirect3DVertexDeclaration IDirect3DVertexDeclaration9
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
316
xdk/xdk_resources.cpp
Normal file
316
xdk/xdk_resources.cpp
Normal file
@ -0,0 +1,316 @@
|
|||||||
|
/* RetroArch - A frontend for libretro.
|
||||||
|
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||||
|
*
|
||||||
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||||
|
* of the GNU General Public License as published by the Free Software Found-
|
||||||
|
* ation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <xgraphics.h>
|
||||||
|
#include "xdk_resources.h"
|
||||||
|
|
||||||
|
#ifdef _XBOX360
|
||||||
|
struct XPR_HEADER
|
||||||
|
{
|
||||||
|
DWORD dwMagic;
|
||||||
|
DWORD dwHeaderSize;
|
||||||
|
DWORD dwDataSize;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define XPR0_MAGIC_VALUE 0x30525058
|
||||||
|
#define XPR1_MAGIC_VALUE 0x31525058
|
||||||
|
#define XPR2_MAGIC_VALUE 0x58505232
|
||||||
|
|
||||||
|
const DWORD eXALLOCAllocatorId_AtgResource = eXALLOCAllocatorId_GameMax;
|
||||||
|
|
||||||
|
PackedResource::PackedResource()
|
||||||
|
{
|
||||||
|
m_pSysMemData = NULL;
|
||||||
|
m_dwSysMemDataSize = 0L;
|
||||||
|
m_pVidMemData = NULL;
|
||||||
|
m_dwVidMemDataSize = 0L;
|
||||||
|
m_pResourceTags = NULL;
|
||||||
|
m_dwNumResourceTags = 0L;
|
||||||
|
m_bInitialized = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PackedResource::~PackedResource()
|
||||||
|
{
|
||||||
|
Destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
void *PackedResource::GetData( const CHAR* strName ) const
|
||||||
|
{
|
||||||
|
if( NULL == m_pResourceTags || NULL == strName )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
#if defined(_XBOX1)
|
||||||
|
for( DWORD i=0; m_pResourceTags[i].strName; i++ )
|
||||||
|
#elif defined(_XBOX360)
|
||||||
|
for( DWORD i = 0; i < m_dwNumResourceTags; i++ )
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
if( !_stricmp( strName, m_pResourceTags[i].strName ) )
|
||||||
|
{
|
||||||
|
return &m_pSysMemData[m_pResourceTags[i].dwOffset];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static __forceinline void* AllocateContiguousMemory( DWORD Size, DWORD Alignment,
|
||||||
|
DWORD Protection = XALLOC_MEMPROTECT_WRITECOMBINE )
|
||||||
|
{
|
||||||
|
#if defined(_XBOX1)
|
||||||
|
return D3D_AllocContiguousMemory(Size, Alignment);
|
||||||
|
#elif defined(_XBOX360)
|
||||||
|
return XMemAlloc( Size, MAKE_XALLOC_ATTRIBUTES( 0, 0, 0, 0, eXALLOCAllocatorId_AtgResource,
|
||||||
|
Alignment, Protection, 0,
|
||||||
|
XALLOC_MEMTYPE_PHYSICAL ) );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static __forceinline void FreeContiguousMemory( void* pData )
|
||||||
|
{
|
||||||
|
#if defined(_XBOX1)
|
||||||
|
return D3D_FreeContiguousMemory(pData);
|
||||||
|
#elif defined(_XBOX360)
|
||||||
|
return XMemFree( pData, MAKE_XALLOC_ATTRIBUTES( 0, 0, 0, 0, eXALLOCAllocatorId_AtgResource,
|
||||||
|
0, 0, 0, XALLOC_MEMTYPE_PHYSICAL ) );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _XBOX1
|
||||||
|
char g_strMediaPath[512] = "D:\\Media\\";
|
||||||
|
static HRESULT FindMediaFile( char *strPath, const char *strFilename )
|
||||||
|
{
|
||||||
|
// Check for valid arguments
|
||||||
|
if( strFilename == NULL || strPath == NULL )
|
||||||
|
{
|
||||||
|
RARCH_ERR("Util_FindMediaFile(): Invalid arguments\n" );
|
||||||
|
return E_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default path is the filename itself as a fully qualified path
|
||||||
|
strcpy( strPath, strFilename );
|
||||||
|
|
||||||
|
// Check for the ':' character to see if the filename is a fully
|
||||||
|
// qualified path. If not, pre-pend the media directory
|
||||||
|
if( strFilename[1] != ':' )
|
||||||
|
sprintf( strPath, "%s%s", g_strMediaPath, strFilename );
|
||||||
|
|
||||||
|
// Try to open the file
|
||||||
|
HANDLE hFile = CreateFile( strPath, GENERIC_READ, FILE_SHARE_READ, NULL,
|
||||||
|
OPEN_EXISTING, 0, NULL );
|
||||||
|
|
||||||
|
if( hFile == INVALID_HANDLE_VALUE )
|
||||||
|
{
|
||||||
|
// Return error
|
||||||
|
CHAR strBuffer[80];
|
||||||
|
sprintf( strBuffer, "FindMediaFile(): Could not find file [%s]\n",
|
||||||
|
strFilename );
|
||||||
|
RARCH_ERR( strBuffer );
|
||||||
|
return 0x82000004;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Found the file. Close the file and return
|
||||||
|
CloseHandle( hFile );
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_XBOX1)
|
||||||
|
HRESULT PackedResource::Create( const char *strFilename,
|
||||||
|
DWORD dwNumResourceTags, XBRESOURCE* pResourceTags)
|
||||||
|
#elif defined(_XBOX360)
|
||||||
|
HRESULT PackedResource::Create( const char *strFilename )
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
#ifdef _XBOX1
|
||||||
|
BOOL bHasResourceOffsetsTable = FALSE;
|
||||||
|
|
||||||
|
// Find the media file
|
||||||
|
CHAR strResourcePath[512];
|
||||||
|
if( FAILED( FindMediaFile( strResourcePath, strFilename ) ) )
|
||||||
|
return E_FAIL;
|
||||||
|
else
|
||||||
|
strFilename = strResourcePath;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Open the file
|
||||||
|
HANDLE hFile;
|
||||||
|
DWORD dwNumBytesRead;
|
||||||
|
hFile = CreateFile( strFilename, GENERIC_READ, FILE_SHARE_READ, NULL,
|
||||||
|
OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL );
|
||||||
|
if( hFile == INVALID_HANDLE_VALUE )
|
||||||
|
{
|
||||||
|
RARCH_ERR( "PackedResource::Create(): File <%s> not found.\n", strFilename );
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read in and verify the XPR magic header
|
||||||
|
XPR_HEADER xprh;
|
||||||
|
bool retval = ReadFile( hFile, &xprh, sizeof( XPR_HEADER ), &dwNumBytesRead, NULL );
|
||||||
|
|
||||||
|
#if defined(_XBOX1)
|
||||||
|
if( xprh.dwMagic == XPR0_MAGIC_VALUE )
|
||||||
|
{
|
||||||
|
bHasResourceOffsetsTable = FALSE;
|
||||||
|
}
|
||||||
|
else if( xprh.dwMagic == XPR1_MAGIC_VALUE )
|
||||||
|
{
|
||||||
|
bHasResourceOffsetsTable = TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#elif defined(_XBOX360)
|
||||||
|
if(!retval)
|
||||||
|
{
|
||||||
|
RARCH_ERR("Error reading XPR header in file %s.\n", strFilename );
|
||||||
|
CloseHandle( hFile );
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( xprh.dwMagic != XPR2_MAGIC_VALUE )
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
RARCH_ERR( "Invalid Xbox Packed Resource (.xpr) file: Magic = 0x%08lx\n", xprh.dwMagic );
|
||||||
|
CloseHandle( hFile );
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compute memory requirements
|
||||||
|
#if defined(_XBOX1)
|
||||||
|
m_dwSysMemDataSize = xprh.dwHeaderSize - sizeof(XPR_HEADER);
|
||||||
|
m_dwVidMemDataSize = xprh.dwTotalSize - xprh.dwHeaderSize;
|
||||||
|
#elif defined(_XBOX360)
|
||||||
|
m_dwSysMemDataSize = xprh.dwHeaderSize;
|
||||||
|
m_dwVidMemDataSize = xprh.dwDataSize;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Allocate memory
|
||||||
|
m_pSysMemData = (BYTE*)malloc(m_dwSysMemDataSize);
|
||||||
|
if( m_pSysMemData == NULL )
|
||||||
|
{
|
||||||
|
RARCH_ERR( "Could not allocate system memory.\n" );
|
||||||
|
m_dwSysMemDataSize = 0;
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pVidMemData = ( BYTE* )AllocateContiguousMemory( m_dwVidMemDataSize,
|
||||||
|
#if defined(_XBOX1)
|
||||||
|
D3DTEXTURE_ALIGNMENT
|
||||||
|
#elif defined(_XBOX360)
|
||||||
|
XALLOC_PHYSICAL_ALIGNMENT_4K
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
|
if( m_pVidMemData == NULL )
|
||||||
|
{
|
||||||
|
RARCH_ERR( "Could not allocate physical memory.\n" );
|
||||||
|
m_dwSysMemDataSize = 0;
|
||||||
|
m_dwVidMemDataSize = 0;
|
||||||
|
free(m_pSysMemData);
|
||||||
|
m_pSysMemData = NULL;
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read in the data from the file
|
||||||
|
if( !ReadFile( hFile, m_pSysMemData, m_dwSysMemDataSize, &dwNumBytesRead, NULL ) ||
|
||||||
|
!ReadFile( hFile, m_pVidMemData, m_dwVidMemDataSize, &dwNumBytesRead, NULL ) )
|
||||||
|
{
|
||||||
|
RARCH_ERR( "Unable to read Xbox Packed Resource (.xpr) file\n" );
|
||||||
|
CloseHandle( hFile );
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Done with the file
|
||||||
|
CloseHandle( hFile );
|
||||||
|
|
||||||
|
#ifdef _XBOX1
|
||||||
|
if (bHasResourceOffsetsTable)
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Extract resource table from the header data
|
||||||
|
m_dwNumResourceTags = *( DWORD* )( m_pSysMemData + 0 );
|
||||||
|
m_pResourceTags = ( XBRESOURCE* )( m_pSysMemData + 4 );
|
||||||
|
|
||||||
|
// Patch up the resources
|
||||||
|
for( DWORD i = 0; i < m_dwNumResourceTags; i++ )
|
||||||
|
{
|
||||||
|
m_pResourceTags[i].strName = ( CHAR* )( m_pSysMemData + ( DWORD )m_pResourceTags[i].strName );
|
||||||
|
#ifdef _XBOX360
|
||||||
|
// Fixup the texture memory
|
||||||
|
if( ( m_pResourceTags[i].dwType & 0xffff0000 ) == ( RESOURCETYPE_TEXTURE & 0xffff0000 ) )
|
||||||
|
{
|
||||||
|
D3DTexture* pTexture = ( D3DTexture* )&m_pSysMemData[m_pResourceTags[i].dwOffset];
|
||||||
|
|
||||||
|
// Adjust Base address according to where memory was allocated
|
||||||
|
XGOffsetBaseTextureAddress( pTexture, m_pVidMemData, m_pVidMemData );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _XBOX1
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _XBOX1
|
||||||
|
// Use user-supplied number of resources and the resource tags
|
||||||
|
if( dwNumResourceTags != 0 || pResourceTags != NULL )
|
||||||
|
{
|
||||||
|
m_pResourceTags = pResourceTags;
|
||||||
|
m_dwNumResourceTags = dwNumResourceTags;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
m_bInitialized = TRUE;
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _XBOX360
|
||||||
|
void PackedResource::GetResourceTags( DWORD* pdwNumResourceTags,
|
||||||
|
XBRESOURCE** ppResourceTags )
|
||||||
|
{
|
||||||
|
if( pdwNumResourceTags )
|
||||||
|
( *pdwNumResourceTags ) = m_dwNumResourceTags;
|
||||||
|
|
||||||
|
if( ppResourceTags )
|
||||||
|
( *ppResourceTags ) = m_pResourceTags;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void PackedResource::Destroy()
|
||||||
|
{
|
||||||
|
free(m_pSysMemData);
|
||||||
|
m_pSysMemData = NULL;
|
||||||
|
m_dwSysMemDataSize = 0L;
|
||||||
|
|
||||||
|
if( m_pVidMemData != NULL )
|
||||||
|
FreeContiguousMemory( m_pVidMemData );
|
||||||
|
m_pVidMemData = NULL;
|
||||||
|
m_dwVidMemDataSize = 0L;
|
||||||
|
|
||||||
|
m_pResourceTags = NULL;
|
||||||
|
m_dwNumResourceTags = 0L;
|
||||||
|
|
||||||
|
m_bInitialized = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL PackedResource::Initialized() const
|
||||||
|
{
|
||||||
|
return m_bInitialized;
|
||||||
|
}
|
153
xdk/xdk_resources.h
Normal file
153
xdk/xdk_resources.h
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
/* RetroArch - A frontend for libretro.
|
||||||
|
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||||
|
*
|
||||||
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||||
|
* of the GNU General Public License as published by the Free Software Found-
|
||||||
|
* ation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef RARCH_XDK_RESOURCE_H
|
||||||
|
#define RARCH_XDK_RESOURCE_H
|
||||||
|
|
||||||
|
#include "xdk_defines.h"
|
||||||
|
|
||||||
|
DWORD XBResource_SizeOf( LPDIRECT3DRESOURCE pResource );
|
||||||
|
|
||||||
|
//structure member offsets matter
|
||||||
|
struct XBRESOURCE
|
||||||
|
{
|
||||||
|
#if defined(_XBOX1)
|
||||||
|
CHAR* strName;
|
||||||
|
DWORD dwOffset;
|
||||||
|
#elif defined(_XBOX360)
|
||||||
|
DWORD dwType;
|
||||||
|
DWORD dwOffset;
|
||||||
|
DWORD dwSize;
|
||||||
|
CHAR* strName;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
// Resource types
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
RESOURCETYPE_USERDATA = ( ( 'U' << 24 ) | ( 'S' << 16 ) | ( 'E' << 8 ) | ( 'R' ) ),
|
||||||
|
RESOURCETYPE_TEXTURE = ( ( 'T' << 24 ) | ( 'X' << 16 ) | ( '2' << 8 ) | ( 'D' ) ),
|
||||||
|
RESOURCETYPE_CUBEMAP = ( ( 'T' << 24 ) | ( 'X' << 16 ) | ( 'C' << 8 ) | ( 'M' ) ),
|
||||||
|
RESOURCETYPE_VOLUMETEXTURE = ( ( 'T' << 24 ) | ( 'X' << 16 ) | ( '3' << 8 ) | ( 'D' ) ),
|
||||||
|
RESOURCETYPE_VERTEXBUFFER = ( ( 'V' << 24 ) | ( 'B' << 16 ) | ( 'U' << 8 ) | ( 'F' ) ),
|
||||||
|
RESOURCETYPE_INDEXBUFFER = ( ( 'I' << 24 ) | ( 'B' << 16 ) | ( 'U' << 8 ) | ( 'F' ) ),
|
||||||
|
RESOURCETYPE_EOF = 0xffffffff
|
||||||
|
};
|
||||||
|
|
||||||
|
class PackedResource
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
BYTE* m_pSysMemData; // Alloc'ed memory for resource headers etc.
|
||||||
|
DWORD m_dwSysMemDataSize;
|
||||||
|
|
||||||
|
BYTE* m_pVidMemData; // Alloc'ed memory for resource data, etc.
|
||||||
|
DWORD m_dwVidMemDataSize;
|
||||||
|
|
||||||
|
XBRESOURCE* m_pResourceTags; // Tags to associate names with the resources
|
||||||
|
DWORD m_dwNumResourceTags; // Number of resource tags
|
||||||
|
BOOL m_bInitialized; // Resource is fully initialized
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Loads the resources out of the specified bundle
|
||||||
|
#if defined(_XBOX1)
|
||||||
|
HRESULT Create( const char *strFilename, DWORD dwNumResourceTags = 0L,
|
||||||
|
XBRESOURCE* pResourceTags = NULL );
|
||||||
|
#elif defined(_XBOX360)
|
||||||
|
HRESULT Create( const char * strFilename );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void Destroy();
|
||||||
|
|
||||||
|
BOOL Initialized() const;
|
||||||
|
|
||||||
|
#ifdef _XBOX360
|
||||||
|
// Retrieves the resource tags
|
||||||
|
void GetResourceTags( DWORD* pdwNumResourceTags, XBRESOURCE** ppResourceTags );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Helper function to make sure a resource is registered
|
||||||
|
LPDIRECT3DRESOURCE RegisterResource( LPDIRECT3DRESOURCE pResource ) const
|
||||||
|
{
|
||||||
|
#ifdef _XBOX1
|
||||||
|
// Register the resource, if it has not yet been registered. We mark
|
||||||
|
// a resource as registered by upping it's reference count.
|
||||||
|
if( pResource && ( pResource->Common & D3DCOMMON_REFCOUNT_MASK ) == 1 )
|
||||||
|
{
|
||||||
|
// Special case CPU-copy push buffers (which live in system memory)
|
||||||
|
if( ( pResource->Common & D3DCOMMON_TYPE_PUSHBUFFER ) &&
|
||||||
|
( pResource->Common & D3DPUSHBUFFER_RUN_USING_CPU_COPY ) )
|
||||||
|
pResource->Data += (DWORD)m_pSysMemData;
|
||||||
|
else
|
||||||
|
pResource->Register( m_pVidMemData );
|
||||||
|
|
||||||
|
pResource->AddRef();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return pResource;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Functions to retrieve resources by their offset
|
||||||
|
void *GetData( DWORD dwOffset ) const
|
||||||
|
{ return &m_pSysMemData[dwOffset]; }
|
||||||
|
|
||||||
|
LPDIRECT3DRESOURCE GetResource( DWORD dwOffset ) const
|
||||||
|
{ return RegisterResource( (LPDIRECT3DRESOURCE)GetData(dwOffset) ); }
|
||||||
|
|
||||||
|
LPDIRECT3DTEXTURE GetTexture( DWORD dwOffset ) const
|
||||||
|
{ return (LPDIRECT3DTEXTURE)GetResource( dwOffset ); }
|
||||||
|
|
||||||
|
LPDIRECT3DCUBETEXTURE GetCubemap( DWORD dwOffset ) const
|
||||||
|
{ return (LPDIRECT3DCUBETEXTURE)GetResource( dwOffset ); }
|
||||||
|
|
||||||
|
LPDIRECT3DVOLUMETEXTURE GetVolumeTexture( DWORD dwOffset ) const
|
||||||
|
{ return (LPDIRECT3DVOLUMETEXTURE)GetResource( dwOffset ); }
|
||||||
|
|
||||||
|
LPDIRECT3DVERTEXBUFFER GetVertexBuffer( DWORD dwOffset ) const
|
||||||
|
{ return (LPDIRECT3DVERTEXBUFFER)GetResource( dwOffset ); }
|
||||||
|
|
||||||
|
#ifdef _XBOX1
|
||||||
|
LPDIRECT3DPUSHBUFFER8 GetPushBuffer( DWORD dwOffset ) const
|
||||||
|
{ return (LPDIRECT3DPUSHBUFFER8)GetResource( dwOffset ); }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Functions to retrieve resources by their name
|
||||||
|
void *GetData( const CHAR* strName ) const;
|
||||||
|
|
||||||
|
LPDIRECT3DRESOURCE GetResource( const CHAR* strName ) const
|
||||||
|
{ return RegisterResource( (LPDIRECT3DRESOURCE)GetData( strName ) ); }
|
||||||
|
|
||||||
|
LPDIRECT3DTEXTURE GetTexture( const CHAR* strName ) const
|
||||||
|
{ return (LPDIRECT3DTEXTURE)GetResource( strName ); }
|
||||||
|
|
||||||
|
LPDIRECT3DCUBETEXTURE GetCubemap( const CHAR* strName ) const
|
||||||
|
{ return (LPDIRECT3DCUBETEXTURE)GetResource( strName ); }
|
||||||
|
|
||||||
|
LPDIRECT3DVOLUMETEXTURE GetVolumeTexture( const CHAR* strName ) const
|
||||||
|
{ return (LPDIRECT3DVOLUMETEXTURE)GetResource( strName ); }
|
||||||
|
|
||||||
|
LPDIRECT3DVERTEXBUFFER GetVertexBuffer( const CHAR* strName ) const
|
||||||
|
{ return (LPDIRECT3DVERTEXBUFFER)GetResource( strName ); }
|
||||||
|
|
||||||
|
#ifdef _XBOX1
|
||||||
|
LPDIRECT3DPUSHBUFFER8 GetPushBuffer( const CHAR* strName ) const
|
||||||
|
{ return (LPDIRECT3DPUSHBUFFER8)GetResource( strName ); }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Constructor/destructor
|
||||||
|
PackedResource();
|
||||||
|
~PackedResource();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif RARCH_XDK_RESOURCE_H
|
Loading…
x
Reference in New Issue
Block a user