(360) Add preliminary WIP XUI menu code - far from complete

This commit is contained in:
TwinAphex51224 2012-01-22 01:43:54 +01:00
parent e46f09c3b1
commit 2fd7c1bb9f
7 changed files with 177 additions and 31 deletions

View File

@ -17,16 +17,41 @@
*/
#include <xtl.h>
#include <xui.h>
#include <xuiapp.h>
#include <stddef.h>
#include <xbdm.h>
#include "menu.h"
#include "xdk360_video.h"
CSSNES app;
int ssnes_main(int argc, char *argv[]);
#undef main
// Temporary, a more sane implementation should go here.
int xui_init (void)
{
HRESULT hr;
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
hr = app.InitShared(vid->xdk360_render_device, &vid->d3dpp, XuiTextureLoader);
if (FAILED(hr))
{
OutputDebugString("Failed initializing XUI application.\n");
return 1;
}
/* Register font */
hr = app.RegisterDefaultTypeface(L"Arial Unicode MS", L"file://game:/media/ssnes.ttf" );
if (FAILED(hr))
{
OutputDebugString("Failed to register default typeface.\n");
return 1;
}
return 0;
}
int main(int argc, char *argv[])
{
@ -44,6 +69,6 @@ int main(int argc, char *argv[])
char *argv_[] = { arg1, arg2, arg3, arg4, arg5, NULL };
return ssnes_main(sizeof(argv_) / sizeof(argv_[0]) - 1, argv_);
xdk360_video_deinit();
xdk360_video_deinit();
}

92
360/menu.cpp Normal file
View File

@ -0,0 +1,92 @@
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
* Copyright (C) 2011-2012 - Daniel De Matteis
*
* Some code herein may be based on code found in BSNES.
*
* SSNES 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.
*
* SSNES 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 SSNES.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <xtl.h>
#include "xdkxui.h"
/* Register custom classes */
HRESULT CSSNES::RegisterXuiClasses (void)
{
return CSSNESMain::Register();
}
/* Unregister custom classes */
HRESULT CSSNES::UnregisterXuiClasses (void)
{
return CSSNESMain::Unregister();
return S_OK;
}
HRESULT APIENTRY XuiTextureLoader(IXuiDevice *pDevice, LPCWSTR szFileName, XUIImageInfo *pImageInfo, IDirect3DTexture9 **ppTex)
{
CONST BYTE *pbTextureData = 0;
UINT cbTextureData = 0;
HXUIRESOURCE hResource = 0;
BOOL bIsMemoryResource = FALSE;
HRESULT hr;
hr = XuiResourceOpen(szFileName, &hResource, &bIsMemoryResource);
if (FAILED(hr))
return hr;
if (bIsMemoryResource)
{
hr = XuiResourceGetBuffer(hResource, &pbTextureData);
if (FAILED(hr))
goto cleanup;
cbTextureData = XuiResourceGetTotalSize(hResource);
}
else
{
hr = XuiResourceRead(hResource, NULL, 0, &cbTextureData);
if (FAILED(hr))
goto cleanup;
pbTextureData = (BYTE *)XuiAlloc(cbTextureData);
if (pbTextureData == 0)
{
hr = E_OUTOFMEMORY;
goto cleanup;
}
hr = XuiResourceRead(hResource, (BYTE*)pbTextureData, cbTextureData, &cbTextureData);
if (FAILED(hr))
goto cleanup;
XuiResourceClose(hResource);
hResource = 0;
}
//Format specific code should be added here to initialize pImageInfo
// and to create an IDirect3DTexture9 interface.
cleanup:
if (bIsMemoryResource && hResource != 0)
XuiResourceReleaseBuffer(hResource, pbTextureData);
else
XuiFree((LPVOID)pbTextureData);
if (hResource != 0)
XuiResourceClose(hResource);
return hr;
}

24
360/menu.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef _MENU_XUI_H_
#define _MENU_XUI_H_
#include <xui.h>
#include <xuiapp.h>
class CSSNES : public CXuiModule
{
protected:
/* Override so that Cssnes can register classes */
virtual HRESULT RegisterXuiClasses();
/* Override so that Cssnes can unregister classes */
virtual HRESULT UnregisterXuiClasses();
};
class CSSNESMain: public CXuiSceneImpl
{
public:
XUI_IMPLEMENT_CLASS(CSSNESMain, L"CSSNESMain", XUI_CLASS_SCENE)
};
HRESULT APIENTRY XuiTextureLoader(IXuiDevice *pDevice, LPCWSTR szFileName, XUIImageInfo *pImageInfo, IDirect3DTexture9 **ppTex);
#endif

View File

@ -1,5 +1,6 @@
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
* Copyright (C) 2011-2012 - Daniel De Matteis
*
* Some code herein may be based on code found in BSNES.
*
@ -70,18 +71,6 @@ static bool g_quitting;
unsigned g_frame_count;
void *g_d3d;
typedef struct xdk360_video
{
IDirect3D9* xdk360_device;
IDirect3DDevice9* xdk360_render_device;
IDirect3DVertexShader9 *pVertexShader;
IDirect3DPixelShader9* pPixelShader;
IDirect3DVertexDeclaration9* pVertexDecl;
IDirect3DVertexBuffer9* vertex_buf;
IDirect3DTexture9* lpTexture;
unsigned last_width, last_height;
} xdk360_video_t;
static void xdk360_gfx_free(void * data)
{
if (g_d3d)
@ -118,22 +107,21 @@ static void *xdk360_gfx_init(const video_info_t *video, const input_driver_t **i
return NULL;
}
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp, sizeof(d3dpp));
ZeroMemory(&vid->d3dpp, sizeof(vid->d3dpp));
d3dpp.BackBufferWidth = 1280;
d3dpp.BackBufferHeight = 720;
d3dpp.BackBufferFormat = (D3DFORMAT)MAKESRGBFMT(D3DFMT_A8R8G8B8);
d3dpp.FrontBufferFormat = (D3DFORMAT)MAKESRGBFMT(D3DFMT_LE_X8R8G8B8);
d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
d3dpp.MultiSampleQuality = 0;
d3dpp.BackBufferCount = 2;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
vid->d3dpp.BackBufferWidth = 1280;
vid->d3dpp.BackBufferHeight = 720;
vid->d3dpp.BackBufferFormat = (D3DFORMAT)MAKESRGBFMT(D3DFMT_A8R8G8B8);
vid->d3dpp.FrontBufferFormat = (D3DFORMAT)MAKESRGBFMT(D3DFMT_LE_X8R8G8B8);
vid->d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
vid->d3dpp.MultiSampleQuality = 0;
vid->d3dpp.BackBufferCount = 2;
vid->d3dpp.EnableAutoDepthStencil = TRUE;
vid->d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
vid->d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
vid->d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
vid->xdk360_device->CreateDevice(0, D3DDEVTYPE_HAL, NULL, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp,
vid->xdk360_device->CreateDevice(0, D3DDEVTYPE_HAL, NULL, D3DCREATE_HARDWARE_VERTEXPROCESSING, &vid->d3dpp,
&vid->xdk360_render_device);
ID3DXBuffer* pShaderCodeV = NULL;

View File

@ -19,6 +19,19 @@
#ifndef _XDK360_VIDEO_H
#define _XDK360_VIDEO_H
typedef struct xdk360_video
{
IDirect3D9* xdk360_device;
IDirect3DDevice9* xdk360_render_device;
IDirect3DVertexShader9 *pVertexShader;
IDirect3DPixelShader9* pPixelShader;
IDirect3DVertexDeclaration9* pVertexDecl;
IDirect3DVertexBuffer9* vertex_buf;
IDirect3DTexture9* lpTexture;
unsigned last_width, last_height;
D3DPRESENT_PARAMETERS d3dpp;
} xdk360_video_t;
void xdk360_video_init(void);
void xdk360_video_deinit(void);

View File

@ -241,6 +241,7 @@
<ClCompile Include="..\..\360\xdk360_audio.cpp" />
<ClCompile Include="..\..\360\xdk360_input.cpp" />
<ClCompile Include="..\..\360\xdk360_video.cpp" />
<ClCompile Include="..\..\360\xdkxui.cpp" />
<ClCompile Include="..\..\audio\hermite.c" />
<ClCompile Include="..\..\audio\utils.c" />
<ClCompile Include="..\..\autosave.c" />

View File

@ -110,6 +110,9 @@
<ClCompile Include="..\..\conf\config_file.c">
<Filter>Source Files\conf</Filter>
</ClCompile>
<ClCompile Include="..\..\360\xdkxui.cpp">
<Filter>Source Files\360</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\ups.h">