Cxbx-Reloaded/Source/Win32/CxbxKrnl/EmuD3D8.cpp

1292 lines
41 KiB
C++
Raw Normal View History

// ******************************************************************
// *
// * .,-::::: .,:: .::::::::. .,:: .:
// * ,;;;'````' `;;;, .,;; ;;;'';;' `;;;, .,;;
// * [[[ '[[,,[[' [[[__[[\. '[[,,[['
// * $$$ Y$$$P $$""""Y$$ Y$$$P
// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo,
// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm,
// *
2003-05-02 06:51:35 +00:00
// * Cxbx->Win32->CxbxKrnl->EmuD3D8.cpp
// *
// * This file is part of the Cxbx project.
// *
// * Cxbx and Cxbe are free software; you can redistribute them
// * and/or modify them under the terms of the GNU General Public
// * License as published by the Free Software Foundation; either
// * version 2 of the license, or (at your option) any later version.
// *
// * This program 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 recieved a copy of the GNU General Public License
// * along with this program; see the file COPYING.
// * If not, write to the Free Software Foundation, Inc.,
// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA.
// *
// * (c) 2002-2003 Aaron Robinson <caustik@caustik.com>
// *
// * All rights reserved
// *
2003-03-07 22:01:44 +00:00
// ******************************************************************
#define _CXBXKRNL_INTERNAL
2003-04-02 02:23:30 +00:00
#define _XBOXKRNL_LOCAL_
// ******************************************************************
// * prevent name collisions
// ******************************************************************
namespace xboxkrnl
{
#include <xboxkrnl/xboxkrnl.h>
};
2003-03-27 06:23:58 +00:00
#include "Emu.h"
2003-04-02 02:23:30 +00:00
#include "EmuFS.h"
2003-04-27 04:56:09 +00:00
#include "EmuKrnl.h"
2003-04-02 02:23:30 +00:00
#include "EmuDInput.h"
2003-05-31 01:17:12 +00:00
#include "EmuShared.h"
2003-03-07 22:01:44 +00:00
// ******************************************************************
// * prevent name collisions
// ******************************************************************
2003-04-02 02:23:30 +00:00
namespace xd3d8
2003-02-21 00:07:28 +00:00
{
2003-04-02 02:23:30 +00:00
#include "xd3d8.h"
};
2003-02-21 00:07:28 +00:00
2003-04-02 02:23:30 +00:00
#include "EmuD3D8.h"
2003-06-05 03:09:52 +00:00
2003-03-04 07:05:25 +00:00
#include "ResCxbxDll.h"
2003-04-02 02:23:30 +00:00
#include <process.h>
#include <locale.h>
// ******************************************************************
2003-05-31 01:17:12 +00:00
// * Global(s)
// ******************************************************************
2003-06-05 03:09:52 +00:00
HWND g_hEmuWindow = NULL; // Rendering Window
2003-05-02 06:51:35 +00:00
// ******************************************************************
2003-05-31 01:17:12 +00:00
// * Static Function(s)
// ******************************************************************
2003-03-27 06:23:58 +00:00
static LRESULT WINAPI EmuMsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
2003-05-05 06:35:37 +00:00
static DWORD WINAPI EmuRenderWindow(LPVOID);
static DWORD WINAPI EmuUpdateTickCount(LPVOID);
2003-05-31 01:17:12 +00:00
// ******************************************************************
// * Static Variable(s)
// ******************************************************************
static xd3d8::LPDIRECT3D8 g_pD3D8 = NULL; // Direct3D8
static xd3d8::LPDIRECT3DDEVICE8 g_pD3D8Device = NULL; // Direct3D8 Device
static Xbe::Header *g_XbeHeader = NULL; // XbeHeader
static uint32 g_XbeHeaderSize = 0; // XbeHeaderSize
static xd3d8::D3DCAPS8 g_D3DCaps; // Direct3D8 Caps
static HBRUSH g_hBgBrush = NULL; // Background Brush
static volatile bool g_ThreadInitialized = false;
static XBVideo g_XBVideo;
2003-05-23 02:55:39 +00:00
// ******************************************************************
2003-05-24 06:06:35 +00:00
// * EmuD3DDefferedRenderState
2003-05-23 02:55:39 +00:00
// ******************************************************************
2003-05-24 06:06:35 +00:00
DWORD *xd3d8::EmuD3DDefferedRenderState;
2003-05-23 02:55:39 +00:00
// ******************************************************************
2003-04-16 19:06:20 +00:00
// * func: EmuD3DInit
// ******************************************************************
2003-04-16 19:06:20 +00:00
VOID EmuD3DInit(Xbe::Header *XbeHeader, uint32 XbeHeaderSize)
2003-02-21 00:07:28 +00:00
{
2003-05-31 01:17:12 +00:00
g_EmuShared->GetXBVideo(&g_XBVideo);
2003-03-21 03:30:00 +00:00
// ******************************************************************
// * store XbeHeader and XbeHeaderSize for further use
// ******************************************************************
2003-05-30 02:08:25 +00:00
g_XbeHeader = XbeHeader;
g_XbeHeaderSize = XbeHeaderSize;
2003-03-21 03:30:00 +00:00
2003-04-16 19:06:20 +00:00
g_ThreadInitialized = false;
2003-02-21 00:07:28 +00:00
// ******************************************************************
2003-05-30 02:08:25 +00:00
// * Create a thread dedicated to timing
2003-02-21 00:07:28 +00:00
// ******************************************************************
{
2003-05-03 08:29:37 +00:00
DWORD dwThreadId;
2003-05-05 06:35:37 +00:00
CreateThread(NULL, NULL, EmuUpdateTickCount, NULL, NULL, &dwThreadId);
2003-05-30 02:08:25 +00:00
}
// ******************************************************************
// * spark up a new thread to handle window message processing
// ******************************************************************
{
DWORD dwThreadId;
2003-05-03 08:29:37 +00:00
CreateThread(NULL, NULL, EmuRenderWindow, NULL, NULL, &dwThreadId);
2003-02-21 00:07:28 +00:00
2003-04-15 08:08:53 +00:00
while(!g_ThreadInitialized)
2003-03-07 07:38:26 +00:00
Sleep(10);
2003-04-26 23:10:35 +00:00
Sleep(50);
2003-02-21 00:07:28 +00:00
}
// ******************************************************************
2003-04-01 02:47:38 +00:00
// * create Direct3D8 and retrieve caps
2003-02-21 00:07:28 +00:00
// ******************************************************************
{
2003-04-02 02:23:30 +00:00
using namespace xd3d8;
2003-04-08 03:34:05 +00:00
2003-02-21 00:07:28 +00:00
// xbox Direct3DCreate8 returns "1" always, so we need our own ptr
g_pD3D8 = Direct3DCreate8(D3D_SDK_VERSION);
2003-04-01 02:47:38 +00:00
2003-04-26 04:32:46 +00:00
if(g_pD3D8 == NULL)
EmuCleanup("Could not initialize Direct3D!");
2003-05-31 01:17:12 +00:00
g_pD3D8->GetDeviceCaps(g_XBVideo.GetDisplayAdapter(), D3DDEVTYPE_HAL, &g_D3DCaps);
2003-02-21 00:07:28 +00:00
}
}
2003-04-16 19:06:20 +00:00
// ******************************************************************
// * func: EmuD3DCleanup
// ******************************************************************
VOID EmuD3DCleanup()
{
EmuDInputCleanup();
return;
}
2003-05-05 06:35:37 +00:00
// ******************************************************************
// * func: EmuUpdateTickCount
// ******************************************************************
DWORD WINAPI EmuUpdateTickCount(LPVOID)
{
2003-05-30 02:08:25 +00:00
timeBeginPeriod(0);
2003-05-05 06:35:37 +00:00
while(true)
{
2003-05-30 02:08:25 +00:00
xboxkrnl::KeTickCount = timeGetTime();
2003-05-20 21:39:25 +00:00
Sleep(1);
2003-05-05 06:35:37 +00:00
}
2003-05-30 02:08:25 +00:00
timeEndPeriod(0);
2003-05-05 06:35:37 +00:00
}
2003-02-21 00:07:28 +00:00
// ******************************************************************
2003-03-27 06:23:58 +00:00
// * func: EmuRenderWindow
2003-02-21 00:07:28 +00:00
// ******************************************************************
2003-05-03 08:29:37 +00:00
DWORD WINAPI EmuRenderWindow(LPVOID)
{
// ******************************************************************
// * register window class
// ******************************************************************
{
2003-04-06 20:07:36 +00:00
#ifdef _DEBUG
HMODULE hCxbxDll = GetModuleHandle("CxbxKrnl.dll");
#else
2003-03-04 07:05:25 +00:00
HMODULE hCxbxDll = GetModuleHandle("Cxbx.dll");
2003-04-06 20:07:36 +00:00
#endif
2003-03-04 07:05:25 +00:00
2003-04-26 04:32:46 +00:00
LOGBRUSH logBrush = {BS_SOLID, RGB(0,0,0)};
g_hBgBrush = CreateBrushIndirect(&logBrush);
WNDCLASSEX wc =
{
sizeof(WNDCLASSEX),
CS_CLASSDC,
2003-03-27 06:23:58 +00:00
EmuMsgProc,
0, 0, GetModuleHandle(NULL),
2003-04-17 01:32:51 +00:00
LoadIcon(hCxbxDll, MAKEINTRESOURCE(IDI_CXBX)),
LoadCursor(NULL, IDC_ARROW),
2003-04-26 04:32:46 +00:00
(HBRUSH)(g_hBgBrush), NULL,
"CxbxRender",
NULL
};
RegisterClassEx(&wc);
}
// ******************************************************************
// * create the window
// ******************************************************************
{
2003-03-21 03:30:00 +00:00
char AsciiTitle[50];
// ******************************************************************
// * retrieve xbe title (if possible)
// ******************************************************************
{
char tAsciiTitle[40] = "Unknown";
uint32 CertAddr = g_XbeHeader->dwCertificateAddr - g_XbeHeader->dwBaseAddr;
if(CertAddr + 0x0C + 40 < g_XbeHeaderSize)
{
Xbe::Certificate *XbeCert = (Xbe::Certificate*)((uint32)g_XbeHeader + CertAddr);
setlocale( LC_ALL, "English" );
wcstombs(tAsciiTitle, XbeCert->wszTitleName, 40);
}
2003-04-08 03:34:05 +00:00
sprintf(AsciiTitle, "Cxbx : Emulating %s", tAsciiTitle);
2003-03-21 03:30:00 +00:00
}
2003-05-31 01:17:12 +00:00
// ******************************************************************
// * Create Window
// ******************************************************************
{
DWORD dwStyle = WS_OVERLAPPEDWINDOW;
2003-06-01 03:19:15 +00:00
2003-05-31 01:17:12 +00:00
int x = 100, y = 100, nWidth = 640, nHeight = 480;
2003-06-01 03:19:15 +00:00
sscanf(g_XBVideo.GetVideoResolution(), "%d x %d", &nWidth, &nHeight);
2003-05-31 01:17:12 +00:00
if(g_XBVideo.GetFullscreen())
{
x = y = nWidth = nHeight = 0;
dwStyle = WS_POPUP;
}
g_hEmuWindow = CreateWindow
(
"CxbxRender", AsciiTitle,
dwStyle, x, y, nWidth, nHeight,
GetDesktopWindow(), NULL, GetModuleHandle(NULL), NULL
);
}
}
// ******************************************************************
// * display the window
// ******************************************************************
{
2003-04-26 08:57:51 +00:00
ShowWindow(g_hEmuWindow, SW_SHOWDEFAULT);
UpdateWindow(g_hEmuWindow);
2003-02-19 20:53:33 +00:00
}
2003-03-23 22:24:41 +00:00
// ******************************************************************
// * initialize direct input
// ******************************************************************
2003-04-26 04:32:46 +00:00
if(!EmuDInputInit())
EmuCleanup("Could not initialize DirectInput!");
2003-03-23 22:24:41 +00:00
2003-02-22 07:49:02 +00:00
// ******************************************************************
// * message processing loop
// ******************************************************************
{
MSG msg;
2003-02-22 07:49:02 +00:00
ZeroMemory(&msg, sizeof(msg));
2003-02-21 00:07:28 +00:00
2003-02-22 07:49:02 +00:00
while(msg.message != WM_QUIT)
2003-02-21 00:07:28 +00:00
{
2003-04-26 23:10:35 +00:00
if(PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
2003-02-22 07:49:02 +00:00
{
2003-04-18 23:44:36 +00:00
g_ThreadInitialized = true;
2003-02-22 07:49:02 +00:00
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
Sleep(10);
2003-02-21 00:07:28 +00:00
}
2003-04-26 04:32:46 +00:00
EmuCleanup(NULL);
2003-02-22 07:49:02 +00:00
}
2003-05-03 08:29:37 +00:00
return 0;
}
2003-02-21 04:51:03 +00:00
// ******************************************************************
2003-03-27 06:23:58 +00:00
// * func: EmuMsgProc
2003-02-21 04:51:03 +00:00
// ******************************************************************
2003-03-27 06:23:58 +00:00
LRESULT WINAPI EmuMsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
2003-02-21 04:51:03 +00:00
{
switch(msg)
{
case WM_DESTROY:
2003-04-26 04:32:46 +00:00
DeleteObject(g_hBgBrush);
2003-02-21 04:51:03 +00:00
PostQuitMessage(0);
return 0;
2003-03-04 07:48:23 +00:00
2003-05-23 02:55:39 +00:00
case WM_KEYDOWN:
2003-04-16 19:06:20 +00:00
if(wParam == VK_ESCAPE)
2003-05-23 02:55:39 +00:00
PostMessage(hWnd, WM_CLOSE, 0, 0);
break;
2003-03-09 09:17:07 +00:00
2003-03-04 07:48:23 +00:00
case WM_CLOSE:
DestroyWindow(hWnd);
break;
2003-03-23 22:24:41 +00:00
case WM_SETCURSOR:
2003-05-31 01:17:12 +00:00
if(g_XBVideo.GetFullscreen())
{
SetCursor(NULL);
return 0;
}
2003-06-01 03:19:15 +00:00
return DefWindowProc(hWnd, msg, wParam, lParam);
2003-04-16 19:06:20 +00:00
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
2003-02-21 04:51:03 +00:00
}
2003-04-16 19:06:20 +00:00
return 0;
2003-02-21 04:51:03 +00:00
}
// ******************************************************************
2003-03-27 06:23:58 +00:00
// * func: EmuIDirect3D8_CreateDevice
// ******************************************************************
2003-04-02 02:23:30 +00:00
HRESULT WINAPI xd3d8::EmuIDirect3D8_CreateDevice
(
UINT Adapter,
D3DDEVTYPE DeviceType,
HWND hFocusWindow,
DWORD BehaviorFlags,
D3DPRESENT_PARAMETERS *pPresentationParameters,
IDirect3DDevice8 **ppReturnedDeviceInterface
)
{
2003-03-27 06:23:58 +00:00
EmuSwapFS(); // Win2k/XP FS
2003-02-19 20:53:33 +00:00
// ******************************************************************
// * debug trace
// ******************************************************************
#ifdef _DEBUG_TRACE
{
2003-05-23 02:55:39 +00:00
printf("EmuD3D8 (0x%X): EmuIDirect3D8_CreateDevice\n"
2003-02-19 20:53:33 +00:00
"(\n"
" Adapter : 0x%.08X\n"
" DeviceType : 0x%.08X\n"
" hFocusWindow : 0x%.08X\n"
" BehaviorFlags : 0x%.08X\n"
" pPresentationParameters : 0x%.08X\n"
" ppReturnedDeviceInterface : 0x%.08X\n"
");\n",
GetCurrentThreadId(), Adapter, DeviceType, hFocusWindow,
BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface);
}
#endif
// ******************************************************************
// * make adjustments to parameters to make sense with windows d3d
// ******************************************************************
{
2003-05-31 01:17:12 +00:00
DeviceType =(g_XBVideo.GetDirect3DDevice() == 0) ? D3DDEVTYPE_HAL : D3DDEVTYPE_REF;
Adapter = g_XBVideo.GetDisplayAdapter();
2003-02-19 20:53:33 +00:00
2003-05-31 01:17:12 +00:00
pPresentationParameters->Windowed = !g_XBVideo.GetFullscreen();
2003-05-30 02:08:25 +00:00
2003-05-31 01:17:12 +00:00
if(g_XBVideo.GetVSync())
pPresentationParameters->SwapEffect = D3DSWAPEFFECT_COPY_VSYNC;
2003-02-23 08:01:01 +00:00
2003-04-26 08:57:51 +00:00
hFocusWindow = g_hEmuWindow;
2003-02-19 20:53:33 +00:00
2003-06-05 03:09:52 +00:00
pPresentationParameters->BackBufferFormat = EmuXB2PC_D3DFormat(pPresentationParameters->BackBufferFormat);
pPresentationParameters->AutoDepthStencilFormat = EmuXB2PC_D3DFormat(pPresentationParameters->AutoDepthStencilFormat);
2003-05-25 07:31:07 +00:00
// ******************************************************************
2003-06-01 03:19:15 +00:00
// * Retrieve Resolution from Configuration
2003-05-25 07:31:07 +00:00
// ******************************************************************
if(pPresentationParameters->Windowed)
{
D3DDISPLAYMODE D3DDisplayMode;
2003-06-05 03:09:52 +00:00
sscanf(g_XBVideo.GetVideoResolution(), "%d x %d", &pPresentationParameters->BackBufferWidth, &pPresentationParameters->BackBufferHeight);
2003-05-31 01:17:12 +00:00
g_pD3D8->GetAdapterDisplayMode(g_XBVideo.GetDisplayAdapter(), &D3DDisplayMode);
2003-05-25 07:31:07 +00:00
pPresentationParameters->BackBufferFormat = D3DDisplayMode.Format;
2003-06-01 03:19:15 +00:00
pPresentationParameters->FullScreen_RefreshRateInHz = 0;
}
else
{
char szBackBufferFormat[16];
sscanf(g_XBVideo.GetVideoResolution(), "%d x %d %*dbit %s (%d hz)",
&pPresentationParameters->BackBufferWidth,
&pPresentationParameters->BackBufferHeight,
szBackBufferFormat,
&pPresentationParameters->FullScreen_RefreshRateInHz);
if(strcmp(szBackBufferFormat, "x1r5g5b5") == 0)
pPresentationParameters->BackBufferFormat = D3DFMT_X1R5G5B5;
if(strcmp(szBackBufferFormat, "r5g6r5") == 0)
pPresentationParameters->BackBufferFormat = D3DFMT_R5G6B5;
if(strcmp(szBackBufferFormat, "x8r8g8b8") == 0)
pPresentationParameters->BackBufferFormat = D3DFMT_X8R8G8B8;
if(strcmp(szBackBufferFormat, "a8r8g8b8") == 0)
pPresentationParameters->BackBufferFormat = D3DFMT_A8R8G8B8;
2003-05-25 07:31:07 +00:00
}
2003-02-19 20:53:33 +00:00
}
2003-02-20 08:07:52 +00:00
// ******************************************************************
2003-05-25 07:31:07 +00:00
// * Detect vertex processing capabilities
2003-02-20 08:07:52 +00:00
// ******************************************************************
2003-05-31 01:17:12 +00:00
if(g_D3DCaps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT && DeviceType != D3DDEVTYPE_HAL)
2003-05-25 07:31:07 +00:00
{
#ifdef _DEBUG_TRACE
printf("EmuD3D8 (0x%X): Using hardware vertex processing\n", GetCurrentThreadId());
#endif
BehaviorFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING;
}
else
{
#ifdef _DEBUG_TRACE
printf("EmuD3D8 (0x%X): Using software vertex processing\n", GetCurrentThreadId());
#endif
BehaviorFlags = D3DCREATE_SOFTWARE_VERTEXPROCESSING;
}
2003-02-20 08:07:52 +00:00
2003-02-19 20:53:33 +00:00
// ******************************************************************
// * redirect to windows d3d
// ******************************************************************
2003-05-03 08:29:37 +00:00
HRESULT hRet = g_pD3D8->CreateDevice
2003-02-19 20:53:33 +00:00
(
Adapter,
DeviceType,
hFocusWindow,
2003-02-22 07:49:02 +00:00
BehaviorFlags,
2003-02-19 20:53:33 +00:00
pPresentationParameters,
ppReturnedDeviceInterface
);
2003-02-20 08:07:52 +00:00
// ******************************************************************
// * it is necessary to store this pointer globally for emulation
// ******************************************************************
2003-02-22 07:49:02 +00:00
g_pD3D8Device = *ppReturnedDeviceInterface;
2003-05-28 22:54:38 +00:00
/* HACK
LPDIRECT3DTEXTURE8 pCxbxTexture;
D3DXCreateTextureFromFile(g_pD3D8Device, "Media\\cxbx.bmp", &pCxbxTexture);
g_pD3D8Device->SetTexture(0, pCxbxTexture);
2003-06-04 02:18:40 +00:00
//*/
EmuSwapFS(); // XBox FS
return hRet;
}
2003-06-05 00:03:28 +00:00
// ******************************************************************
// * func: EmuIDirect3DDevice8_CreateTexture
// ******************************************************************
HRESULT WINAPI xd3d8::EmuIDirect3DDevice8_CreateTexture
(
UINT Width,
UINT Height,
UINT Levels,
DWORD Usage,
D3DFORMAT Format,
D3DPOOL Pool,
IDirect3DTexture8 **ppTexture
)
{
EmuSwapFS(); // Win2k/XP FS
// ******************************************************************
// * debug trace
// ******************************************************************
#ifdef _DEBUG_TRACE
{
printf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_CreateTexture\n"
"(\n"
" Width : 0x%.08X\n"
" Height : 0x%.08X\n"
" Levels : 0x%.08X\n"
" Usage : 0x%.08X\n"
" Format : 0x%.08X\n"
" Pool : 0x%.08X\n"
" ppTexture : 0x%.08X\n"
");\n",
GetCurrentThreadId(), Width, Height, Levels, Usage, Format, Pool, ppTexture);
}
#endif
2003-06-05 03:09:52 +00:00
// Convert Format (Xbox->PC)
Format = EmuXB2PC_D3DFormat(Format);
2003-06-05 00:03:28 +00:00
// ******************************************************************
// * redirect to windows d3d
// ******************************************************************
HRESULT hRet = g_pD3D8Device->CreateTexture
(
Width, Height, Levels,
0, // TODO: Xbox Allows a border to be drawn (maybe hack this in software ;[)
Format, D3DPOOL_DEFAULT, ppTexture
);
EmuSwapFS(); // XBox FS
return hRet;
}
2003-06-04 02:18:40 +00:00
// ******************************************************************
// * func: EmuIDirect3DDevice8_GetDisplayMode
// ******************************************************************
HRESULT WINAPI xd3d8::EmuIDirect3DDevice8_GetDisplayMode
(
X_D3DDISPLAYMODE *pMode
)
{
EmuSwapFS(); // Win2k/XP FS
// ******************************************************************
// * debug trace
// ******************************************************************
#ifdef _DEBUG_TRACE
{
printf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_GetDisplayMode\n"
"(\n"
" pMode : 0x%.08X\n"
");\n",
GetCurrentThreadId(), pMode);
}
#endif
HRESULT hRet;
// ******************************************************************
// * make adjustments to parameters to make sense with windows d3d
// ******************************************************************
{
D3DDISPLAYMODE *pPCMode = (D3DDISPLAYMODE*)pMode;
hRet = g_pD3D8Device->GetDisplayMode(pPCMode);
2003-06-05 03:09:52 +00:00
// Convert Format (PC->Xbox)
pMode->Format = EmuPC2XB_D3DFormat(pPCMode->Format);
2003-06-04 02:18:40 +00:00
// TODO: Make this configurable in the future?
2003-06-05 03:09:52 +00:00
pMode->Flags = 0x000000A1; // D3DPRESENTFLAG_FIELD | D3DPRESENTFLAG_INTERLACED | D3DPRESENTFLAG_LOCKABLE_BACKBUFFER
2003-06-04 02:18:40 +00:00
}
2003-03-27 06:23:58 +00:00
EmuSwapFS(); // XBox FS
2003-02-19 20:53:33 +00:00
2003-05-03 08:29:37 +00:00
return hRet;
2003-02-19 20:53:33 +00:00
}
// ******************************************************************
2003-03-27 06:23:58 +00:00
// * func: EmuIDirect3DDevice8_Clear
2003-02-19 20:53:33 +00:00
// ******************************************************************
2003-04-02 02:23:30 +00:00
HRESULT WINAPI xd3d8::EmuIDirect3DDevice8_Clear
2003-02-19 20:53:33 +00:00
(
DWORD Count,
CONST D3DRECT *pRects,
DWORD Flags,
D3DCOLOR Color,
float Z,
DWORD Stencil
)
{
2003-03-27 06:23:58 +00:00
EmuSwapFS(); // Win2k/XP FS
2003-02-19 20:53:33 +00:00
// ******************************************************************
// * debug trace
// ******************************************************************
#ifdef _DEBUG_TRACE
{
2003-05-23 02:55:39 +00:00
printf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_Clear\n"
2003-02-19 20:53:33 +00:00
"(\n"
" Count : 0x%.08X\n"
" pRects : 0x%.08X\n"
" Flags : 0x%.08X\n"
" Color : 0x%.08X\n"
" Z : 0x%.08X\n"
" Stencil : 0x%.08X\n"
");\n",
GetCurrentThreadId(), Count, pRects, Flags,
Color, Z, Stencil);
}
#endif
2003-05-28 07:21:41 +00:00
2003-02-19 20:53:33 +00:00
// ******************************************************************
// * make adjustments to parameters to make sense with windows d3d
// ******************************************************************
{
2003-02-21 20:33:21 +00:00
// TODO: D3DCLEAR_TARGET_A, *R, *G, *B don't exist on windows
2003-02-22 07:49:02 +00:00
DWORD newFlags = 0;
2003-02-20 08:07:52 +00:00
2003-02-22 07:49:02 +00:00
if(Flags & 0x000000f0l)
newFlags |= D3DCLEAR_TARGET;
2003-02-20 08:07:52 +00:00
2003-02-22 07:49:02 +00:00
if(Flags & 0x00000001l)
newFlags |= D3DCLEAR_ZBUFFER;
2003-02-20 08:07:52 +00:00
2003-02-22 07:49:02 +00:00
if(Flags & 0x00000002l)
newFlags |= D3DCLEAR_STENCIL;
2003-02-20 08:07:52 +00:00
2003-02-22 07:49:02 +00:00
Flags = newFlags;
2003-02-19 20:53:33 +00:00
}
2003-02-20 08:07:52 +00:00
HRESULT ret = g_pD3D8Device->Clear(Count, pRects, Flags, Color, Z, Stencil);
2003-02-19 20:53:33 +00:00
2003-03-27 06:23:58 +00:00
EmuSwapFS(); // XBox FS
2003-02-19 20:53:33 +00:00
return ret;
}
2003-02-21 00:07:28 +00:00
2003-05-05 06:35:37 +00:00
// ******************************************************************
// * func: EmuIDirect3DDevice8_Present
// ******************************************************************
HRESULT WINAPI xd3d8::EmuIDirect3DDevice8_Present
(
CONST RECT* pSourceRect,
CONST RECT* pDestRect,
PVOID pDummy1,
PVOID pDummy2
)
{
EmuSwapFS(); // Win2k/XP FS
// ******************************************************************
// * debug trace
// ******************************************************************
#ifdef _DEBUG_TRACE
{
2003-05-23 02:55:39 +00:00
printf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_Present\n"
2003-05-05 06:35:37 +00:00
"(\n"
" pSourceRect : 0x%.08X\n"
" pDestRect : 0x%.08X\n"
" pDummy1 : 0x%.08X\n"
" pDummy2 : 0x%.08X\n"
");\n",
GetCurrentThreadId(), pSourceRect, pDestRect, pDummy1, pDummy2);
}
#endif
HRESULT ret = g_pD3D8Device->Present(pSourceRect, pDestRect, (HWND)pDummy1, (CONST RGNDATA*)pDummy2);
EmuSwapFS(); // XBox FS
return ret;
}
2003-02-21 00:07:28 +00:00
// ******************************************************************
2003-03-27 06:23:58 +00:00
// * func: EmuIDirect3DDevice8_Swap
2003-02-21 00:07:28 +00:00
// ******************************************************************
2003-04-02 02:23:30 +00:00
HRESULT WINAPI xd3d8::EmuIDirect3DDevice8_Swap
2003-02-21 00:07:28 +00:00
(
DWORD Flags
)
{
2003-03-27 06:23:58 +00:00
EmuSwapFS(); // Win2k/XP FS
2003-02-21 00:07:28 +00:00
// ******************************************************************
// * debug trace
// ******************************************************************
#ifdef _DEBUG_TRACE
{
2003-05-23 02:55:39 +00:00
printf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_Swap\n"
2003-02-21 00:07:28 +00:00
"(\n"
" Flags : 0x%.08X\n"
");\n",
GetCurrentThreadId(), Flags);
}
#endif
// TODO: Ensure this flag is always the same across library versions
if(Flags != 0)
2003-05-28 07:21:41 +00:00
EmuCleanup("xd3d8::EmuIDirect3DDevice8_Swap: Flags != 0");
2003-02-21 00:07:28 +00:00
// Swap(0) is equivalent to present(0,0,0,0)
HRESULT ret = g_pD3D8Device->Present(0, 0, 0, 0);
2003-03-27 06:23:58 +00:00
EmuSwapFS(); // XBox FS
2003-02-21 00:07:28 +00:00
return ret;
2003-05-02 02:42:29 +00:00
}
2003-06-05 00:03:28 +00:00
// ******************************************************************
// * func: EmuIDirect3DSurface8_GetDesc
// ******************************************************************
HRESULT WINAPI xd3d8::EmuIDirect3DSurface8_GetDesc
(
PVOID pThis,
X_D3DSURFACE_DESC *pDesc
)
{
EmuSwapFS(); // Win2k/XP FS
// ******************************************************************
// * debug trace
// ******************************************************************
#ifdef _DEBUG_TRACE
{
printf("EmuD3D8 (0x%X): EmuIDirect3DSurface8_GetDesc\n"
"(\n"
" pThis : 0x%.08X\n"
" pDesc : 0x%.08X\n"
");\n",
GetCurrentThreadId(), pThis, pDesc);
}
#endif
HRESULT hRet = ((IDirect3DSurface8*)pThis)->GetDesc((D3DSURFACE_DESC*)pDesc);
// ******************************************************************
// * Rearrange into windows format (remove D3DPool)
// ******************************************************************
{
D3DSURFACE_DESC *pPCDesc = (D3DSURFACE_DESC*)pDesc;
2003-06-05 03:09:52 +00:00
// Convert Format (PC->Xbox)
pDesc->Format = EmuPC2XB_D3DFormat(pPCDesc->Format);
2003-06-05 00:03:28 +00:00
pDesc->Type = pPCDesc->Type;
2003-06-05 03:09:52 +00:00
if(pDesc->Type > 7)
EmuCleanup("EmuIDirect3DSurface8_GetDesc: pDesc->Type > 7");
2003-06-05 00:03:28 +00:00
pDesc->Usage = pPCDesc->Usage;
pDesc->Size = pPCDesc->Size;
// TODO: Convert from Xbox to PC!!
if(pPCDesc->MultiSampleType == D3DMULTISAMPLE_NONE)
pDesc->MultiSampleType = (xd3d8::D3DMULTISAMPLE_TYPE)0x0011;
else
EmuCleanup("EmuIDirect3DSurface8_GetDesc Unknown Multisample format!");
pDesc->Width = pPCDesc->Width;
pDesc->Height = pPCDesc->Height;
}
EmuSwapFS(); // XBox FS
return hRet;
}
2003-06-05 03:09:52 +00:00
// ******************************************************************
// * func: EmuIDirect3DSurface8_LockRect
// ******************************************************************
HRESULT WINAPI xd3d8::EmuIDirect3DSurface8_LockRect
(
PVOID pThis,
D3DLOCKED_RECT *pLockedRect,
CONST RECT *pRect,
DWORD Flags
)
{
EmuSwapFS(); // Win2k/XP FS
// ******************************************************************
// * debug trace
// ******************************************************************
#ifdef _DEBUG_TRACE
{
printf("EmuD3D8 (0x%X): EmuIDirect3DSurface8_LockRect\n"
"(\n"
" pThis : 0x%.08X\n"
" pLockedRect : 0x%.08X\n"
" pRect : 0x%.08X\n"
" Flags : 0x%.08X\n"
");\n",
GetCurrentThreadId(), pThis, pLockedRect, pRect, Flags);
}
#endif
if(Flags == 0x40)
{
printf("EmuIDirect3DSurface8_LockRect: WARNING, TILE LOCK!\n");
Flags = 0;
}
else if(Flags != 0)
EmuCleanup("EmuIDirect3DSurface8_LockRect: Unknown Flags!");
HRESULT hRet = ((IDirect3DSurface8*)pThis)->LockRect(pLockedRect, pRect, Flags);
EmuSwapFS(); // XBox FS
return hRet;
}
2003-06-05 00:03:28 +00:00
// ******************************************************************
// * func: EmuIDirect3DTexture8_GetSurfaceLevel
// ******************************************************************
HRESULT WINAPI xd3d8::EmuIDirect3DTexture8_GetSurfaceLevel
(
PVOID pThis,
UINT Level,
IDirect3DSurface8 **ppSurfaceLevel
)
{
EmuSwapFS(); // Win2k/XP FS
// ******************************************************************
// * debug trace
// ******************************************************************
#ifdef _DEBUG_TRACE
{
printf("EmuD3D8 (0x%X): EmuIDirect3DTexture8_GetSurfaceLevel\n"
"(\n"
" pThis : 0x%.08X\n"
" Level : 0x%.08X\n"
" ppSurfaceLevel : 0x%.08X\n"
");\n",
GetCurrentThreadId(), pThis, Level, ppSurfaceLevel);
}
#endif
HRESULT hRet = ((IDirect3DTexture8*)pThis)->GetSurfaceLevel(Level, ppSurfaceLevel);
EmuSwapFS(); // XBox FS
return hRet;
}
2003-05-02 02:42:29 +00:00
// ******************************************************************
// * func: EmuIDirect3DDevice8_CreateVertexBuffer
// ******************************************************************
2003-05-06 06:40:09 +00:00
HRESULT WINAPI xd3d8::EmuIDirect3DDevice8_CreateVertexBuffer
(
UINT Length,
DWORD Usage,
DWORD FVF,
D3DPOOL Pool,
D3DVertexBuffer **ppVertexBuffer
)
{
*ppVertexBuffer = EmuIDirect3DDevice8_CreateVertexBuffer2(Length);
return D3D_OK;
}
// ******************************************************************
// * func: EmuIDirect3DDevice8_CreateVertexBuffer2
// ******************************************************************
2003-05-02 02:42:29 +00:00
xd3d8::D3DVertexBuffer* WINAPI xd3d8::EmuIDirect3DDevice8_CreateVertexBuffer2
(
UINT Length
)
{
EmuSwapFS(); // Win2k/XP FS
// ******************************************************************
// * debug trace
// ******************************************************************
#ifdef _DEBUG_TRACE
{
2003-05-23 02:55:39 +00:00
printf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_CreateVertexBuffer2\n"
2003-05-02 02:42:29 +00:00
"(\n"
" Length : 0x%.08X\n"
");\n",
GetCurrentThreadId(), Length);
}
#endif
IDirect3DVertexBuffer8 *ppVertexBuffer=NULL;
HRESULT hRet = g_pD3D8Device->CreateVertexBuffer
(
2003-05-23 02:55:39 +00:00
Length,
D3DUSAGE_WRITEONLY,
0,
D3DPOOL_DEFAULT,
&ppVertexBuffer
2003-05-02 02:42:29 +00:00
);
EmuSwapFS(); // XBox FS
return (xd3d8::D3DVertexBuffer*)ppVertexBuffer;
}
2003-05-05 06:35:37 +00:00
// ******************************************************************
// * func: EmuIDirect3DDevice8_SetRenderState_CullMode
// ******************************************************************
VOID WINAPI xd3d8::EmuIDirect3DDevice8_SetRenderState_CullMode
(
DWORD Value
)
{
EmuSwapFS(); // Win2k/XP FS
// ******************************************************************
// * debug trace
// ******************************************************************
#ifdef _DEBUG_TRACE
{
2003-05-23 02:55:39 +00:00
printf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_SetRenderState_CullMode\n"
2003-05-05 06:35:37 +00:00
"(\n"
" Value : 0x%.08X\n"
");\n",
GetCurrentThreadId(), Value);
}
#endif
// ******************************************************************
// * Convert from Xbox D3D to PC D3D enumeration
// ******************************************************************
// TODO: XDK-Specific Tables? So far they are the same
switch(Value)
{
case 0:
Value = D3DCULL_NONE;
break;
case 0x900:
Value = D3DCULL_CW;
break;
case 0x901:
Value = D3DCULL_CCW;
break;
2003-06-05 03:09:52 +00:00
default:
EmuCleanup("EmuIDirect3DDevice8_SetRenderState_CullMode: Unknown Cullmode");
2003-05-05 06:35:37 +00:00
}
g_pD3D8Device->SetRenderState(D3DRS_CULLMODE, Value);
EmuSwapFS(); // XBox FS
return;
}
2003-05-23 02:55:39 +00:00
// ******************************************************************
// * func: EmuIDirect3DDevice8_SetRenderState_ZEnable
// ******************************************************************
VOID WINAPI xd3d8::EmuIDirect3DDevice8_SetRenderState_ZEnable
(
DWORD Value
)
{
EmuSwapFS(); // Win2k/XP FS
// ******************************************************************
// * debug trace
// ******************************************************************
#ifdef _DEBUG_TRACE
{
printf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_SetRenderState_ZEnable\n"
"(\n"
" Value : 0x%.08X\n"
");\n",
GetCurrentThreadId(), Value);
}
#endif
g_pD3D8Device->SetRenderState(D3DRS_ZENABLE, Value);
EmuSwapFS(); // XBox FS
return;
}
2003-05-05 06:35:37 +00:00
// ******************************************************************
// * func: EmuIDirect3DDevice8_SetTransform
// ******************************************************************
VOID WINAPI xd3d8::EmuIDirect3DDevice8_SetTransform
(
D3DTRANSFORMSTATETYPE State,
CONST D3DMATRIX *pMatrix
)
{
EmuSwapFS(); // Win2k/XP FS
// ******************************************************************
// * debug trace
// ******************************************************************
#ifdef _DEBUG_TRACE
{
2003-05-23 02:55:39 +00:00
printf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_SetTransform\n"
2003-05-05 06:35:37 +00:00
"(\n"
" State : 0x%.08X\n"
" pMatrix : 0x%.08X\n"
");\n",
GetCurrentThreadId(), State, pMatrix);
}
#endif
// ******************************************************************
// * Convert from Xbox D3D to PC D3D enumeration
// ******************************************************************
// TODO: XDK-Specific Tables? So far they are the same
if((uint32)State < 2)
State = (D3DTRANSFORMSTATETYPE)(State + 2);
else if((uint32)State < 6)
State = (D3DTRANSFORMSTATETYPE)(State + 14);
else if((uint32)State < 9)
State = D3DTS_WORLDMATRIX(State-6);
g_pD3D8Device->SetTransform(State, pMatrix);
EmuSwapFS(); // XBox FS
return;
}
2003-05-02 02:42:29 +00:00
// ******************************************************************
// * func: EmuIDirect3DVertexBuffer8_Lock
// ******************************************************************
2003-05-06 06:40:09 +00:00
VOID WINAPI xd3d8::EmuIDirect3DVertexBuffer8_Lock
2003-05-02 02:42:29 +00:00
(
D3DVertexBuffer *ppVertexBuffer,
2003-05-06 06:40:09 +00:00
UINT OffsetToLock,
UINT SizeToLock,
BYTE **ppbData,
2003-05-02 02:42:29 +00:00
DWORD Flags
)
{
EmuSwapFS(); // Win2k/XP FS
// ******************************************************************
// * debug trace
// ******************************************************************
#ifdef _DEBUG_TRACE
{
2003-05-23 02:55:39 +00:00
printf("EmuD3D8 (0x%X): EmuIDirect3DVertexBuffer8_Lock\n"
2003-05-06 06:40:09 +00:00
"(\n"
" ppVertexBuffer : 0x%.08X\n"
" OffsetToLock : 0x%.08X\n"
" SizeToLock : 0x%.08X\n"
" ppbData : 0x%.08X\n"
" Flags : 0x%.08X\n"
");\n",
GetCurrentThreadId(), ppVertexBuffer, OffsetToLock, SizeToLock, ppbData, Flags);
}
#endif
HRESULT hRet = ((IDirect3DVertexBuffer8*)ppVertexBuffer)->Lock(OffsetToLock, SizeToLock, ppbData, Flags);
EmuSwapFS(); // XBox FS
return;
}
// ******************************************************************
// * func: EmuIDirect3DVertexBuffer8_Lock2
// ******************************************************************
BYTE* WINAPI xd3d8::EmuIDirect3DVertexBuffer8_Lock2
(
D3DVertexBuffer *ppVertexBuffer,
DWORD Flags
)
{
EmuSwapFS(); // Win2k/XP FS
// ******************************************************************
// * debug trace
// ******************************************************************
#ifdef _DEBUG_TRACE
{
2003-05-23 02:55:39 +00:00
printf("EmuD3D8 (0x%X): EmuIDirect3DVertexBuffer8_Lock2\n"
2003-05-02 02:42:29 +00:00
"(\n"
" ppVertexBuffer : 0x%.08X\n"
" Flags : 0x%.08X\n"
");\n",
GetCurrentThreadId(), ppVertexBuffer, Flags);
}
#endif
BYTE *pbData = NULL;
HRESULT hRet = ((IDirect3DVertexBuffer8*)ppVertexBuffer)->Lock(0, 0, &pbData, Flags);
EmuSwapFS(); // XBox FS
return pbData;
}
// ******************************************************************
// * func: EmuIDirect3DDevice8_SetStreamSource
// ******************************************************************
2003-05-06 06:40:09 +00:00
HRESULT WINAPI xd3d8::EmuIDirect3DDevice8_SetStreamSource
2003-05-02 02:42:29 +00:00
(
UINT StreamNumber,
D3DVertexBuffer *pStreamData,
UINT Stride
)
{
EmuSwapFS(); // Win2k/XP FS
// ******************************************************************
// * debug trace
// ******************************************************************
#ifdef _DEBUG_TRACE
{
2003-05-23 02:55:39 +00:00
printf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_SetStreamSource\n"
2003-05-02 02:42:29 +00:00
"(\n"
" StreamNumber : 0x%.08X\n"
" pStreamData : 0x%.08X\n"
" Stride : 0x%.08X\n"
");\n",
GetCurrentThreadId(), StreamNumber, pStreamData, Stride);
}
#endif
((IDirect3DVertexBuffer8*)pStreamData)->Unlock();
2003-05-23 02:55:39 +00:00
HRESULT hRet = g_pD3D8Device->SetStreamSource(StreamNumber, (IDirect3DVertexBuffer8*)pStreamData, Stride);
2003-05-02 02:42:29 +00:00
EmuSwapFS(); // XBox FS
2003-05-06 06:40:09 +00:00
return hRet;
2003-05-02 02:42:29 +00:00
}
// ******************************************************************
// * func: EmuIDirect3DDevice8_SetVertexShader
// ******************************************************************
2003-05-06 06:40:09 +00:00
HRESULT WINAPI xd3d8::EmuIDirect3DDevice8_SetVertexShader
2003-05-02 02:42:29 +00:00
(
DWORD Handle
)
{
EmuSwapFS(); // Win2k/XP FS
// ******************************************************************
// * debug trace
// ******************************************************************
#ifdef _DEBUG_TRACE
{
2003-05-23 02:55:39 +00:00
printf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_SetVertexShader\n"
2003-05-02 02:42:29 +00:00
"(\n"
" Handle : 0x%.08X\n"
");\n",
GetCurrentThreadId(), Handle);
}
#endif
2003-05-23 02:55:39 +00:00
HRESULT hRet = g_pD3D8Device->SetVertexShader(Handle);
2003-05-02 02:42:29 +00:00
EmuSwapFS(); // XBox FS
2003-05-06 06:40:09 +00:00
return hRet;
2003-05-02 02:42:29 +00:00
}
// ******************************************************************
// * func: EmuIDirect3DDevice8_DrawVertices
// ******************************************************************
2003-05-06 06:40:09 +00:00
HRESULT WINAPI xd3d8::EmuIDirect3DDevice8_DrawVertices
2003-05-02 02:42:29 +00:00
(
D3DPRIMITIVETYPE PrimitiveType,
UINT StartVertex,
UINT VertexCount
)
{
EmuSwapFS(); // Win2k/XP FS
// ******************************************************************
// * debug trace
// ******************************************************************
#ifdef _DEBUG_TRACE
{
2003-05-23 02:55:39 +00:00
printf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_DrawVertices\n"
2003-05-02 02:42:29 +00:00
"(\n"
" PrimitiveType : 0x%.08X\n"
" StartVertex : 0x%.08X\n"
" VertexCount : 0x%.08X\n"
");\n",
GetCurrentThreadId(), PrimitiveType, StartVertex, VertexCount);
}
#endif
2003-05-25 07:31:07 +00:00
// Certain D3DRS values need to be checked on each Draw[Indexed]Vertices
2003-05-28 07:21:41 +00:00
g_pD3D8Device->SetRenderState(D3DRS_LIGHTING, xd3d8::EmuD3DDefferedRenderState[10]);
g_pD3D8Device->SetRenderState(D3DRS_AMBIENTMATERIALSOURCE, xd3d8::EmuD3DDefferedRenderState[20]);
2003-05-25 07:31:07 +00:00
g_pD3D8Device->SetRenderState(D3DRS_AMBIENT, xd3d8::EmuD3DDefferedRenderState[23]);
2003-05-23 02:55:39 +00:00
2003-05-02 02:42:29 +00:00
UINT PrimitiveCount = D3DVertex2PrimitiveCount(PrimitiveType, VertexCount);
// Convert from Xbox to PC enumeration
PrimitiveType = EmuPrimitiveType(PrimitiveType);
HRESULT hRet = g_pD3D8Device->DrawPrimitive
(
PrimitiveType,
StartVertex,
2003-05-23 02:55:39 +00:00
PrimitiveCount
2003-05-02 02:42:29 +00:00
);
EmuSwapFS(); // XBox FS
2003-05-06 06:40:09 +00:00
return hRet;
2003-05-02 02:42:29 +00:00
}
2003-05-28 07:21:41 +00:00
// ******************************************************************
// * func: EmuIDirect3DDevice8_SetLight
// ******************************************************************
HRESULT WINAPI xd3d8::EmuIDirect3DDevice8_SetLight
(
DWORD Index,
CONST D3DLIGHT8 *pLight
)
{
EmuSwapFS(); // Win2k/XP FS
// ******************************************************************
// * debug trace
// ******************************************************************
#ifdef _DEBUG_TRACE
{
printf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_SetLight\n"
"(\n"
" Index : 0x%.08X\n"
" pLight : 0x%.08X\n"
");\n",
GetCurrentThreadId(), Index, pLight);
}
#endif
HRESULT hRet = g_pD3D8Device->SetLight(Index, pLight);
EmuSwapFS(); // XBox FS
return hRet;
}
// ******************************************************************
// * func: EmuIDirect3DDevice8_SetMaterial
// ******************************************************************
HRESULT WINAPI xd3d8::EmuIDirect3DDevice8_SetMaterial
(
CONST D3DMATERIAL8 *pMaterial
)
{
EmuSwapFS(); // Win2k/XP FS
// ******************************************************************
// * debug trace
// ******************************************************************
#ifdef _DEBUG_TRACE
{
printf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_SetMaterial\n"
"(\n"
" pMaterial : 0x%.08X\n"
");\n",
GetCurrentThreadId(), pMaterial);
}
#endif
HRESULT hRet = g_pD3D8Device->SetMaterial(pMaterial);
EmuSwapFS(); // XBox FS
return hRet;
}
// ******************************************************************
// * func: EmuIDirect3DDevice8_LightEnable
// ******************************************************************
HRESULT WINAPI xd3d8::EmuIDirect3DDevice8_LightEnable
(
DWORD Index,
BOOL bEnable
)
{
EmuSwapFS(); // Win2k/XP FS
// ******************************************************************
// * debug trace
// ******************************************************************
#ifdef _DEBUG_TRACE
{
printf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_LightEnable\n"
"(\n"
" Index : 0x%.08X\n"
" bEnable : 0x%.08X\n"
");\n",
GetCurrentThreadId(), Index, bEnable);
}
#endif
HRESULT hRet = g_pD3D8Device->LightEnable(Index, bEnable);
EmuSwapFS(); // XBox FS
return hRet;
}