diff --git a/Cxbx.opt b/Cxbx.opt index 76c92f5b5..f3e304ebc 100644 Binary files a/Cxbx.opt and b/Cxbx.opt differ diff --git a/CxbxKrnl.dsp b/CxbxKrnl.dsp index fddf1e3cc..2faaad432 100644 --- a/CxbxKrnl.dsp +++ b/CxbxKrnl.dsp @@ -132,7 +132,7 @@ SOURCE=.\Doc\Todo.txt # Begin Group "Include" # PROP Default_Filter "" -# Begin Group "HLEDataBase.h" +# Begin Group "HLEDataBase (h)" # PROP Default_Filter "" # Begin Source File @@ -212,6 +212,26 @@ SOURCE=.\Include\Win32\CxbxKrnl\HLEDataBase\XNet.1.0.3911.h SOURCE=.\Include\Win32\CxbxKrnl\HLEDataBase\XOnline.1.0.4361.h # End Source File # End Group +# Begin Group "EmuD3D8 (h)" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\Include\Win32\CxbxKrnl\EmuD3D8\Convert.h +# End Source File +# Begin Source File + +SOURCE=.\Include\Win32\CxbxKrnl\EmuD3D8\PushBuffer.h +# End Source File +# Begin Source File + +SOURCE=.\Include\Win32\CxbxKrnl\EmuD3D8\VertexBuffer.h +# End Source File +# Begin Source File + +SOURCE=.\Include\Win32\CxbxKrnl\EmuD3D8\VertexShader.h +# End Source File +# End Group # Begin Source File SOURCE=.\Include\Win32\AlignPosfix1.h @@ -234,15 +254,7 @@ SOURCE=.\Include\Win32\CxbxKrnl\EmuD3D8.h # End Source File # Begin Source File -SOURCE=.\Include\Win32\CxbxKrnl\EmuD3D8Conv.h -# End Source File -# Begin Source File - -SOURCE=.\Include\Win32\CxbxKrnl\EmuD3D8PushBuffer.h -# End Source File -# Begin Source File - -SOURCE=.\Include\Win32\CxbxKrnl\EmuD3D8VertexShader.h +SOURCE=.\Include\Win32\CxbxKrnl\EmuD3D8Types.h # End Source File # Begin Source File @@ -328,7 +340,7 @@ SOURCE=.\Resource\CxbxDll.rc # Begin Group "Source" # PROP Default_Filter "" -# Begin Group "HLEDataBase.inl" +# Begin Group "HLEDataBase (inl)" # PROP Default_Filter "" # Begin Source File @@ -427,6 +439,26 @@ SOURCE=.\Source\Win32\CxbxKrnl\HLEDataBase\XOnline.1.0.4361.inl # PROP Exclude_From_Build 1 # End Source File # End Group +# Begin Group "EmuD3D8 (cpp)" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\Source\Win32\CxbxKrnl\EmuDirect3D\Convert.cpp +# End Source File +# Begin Source File + +SOURCE=.\Source\Win32\CxbxKrnl\EmuD3D8\PushBuffer.cpp +# End Source File +# Begin Source File + +SOURCE=.\Source\Win32\CxbxKrnl\EmuD3D8\VertexBuffer.cpp +# End Source File +# Begin Source File + +SOURCE=.\Source\Win32\CxbxKrnl\EmuD3D8\VertexShader.cpp +# End Source File +# End Group # Begin Source File SOURCE=.\Source\Win32\CxbxKrnl\Emu.cpp @@ -437,18 +469,6 @@ SOURCE=.\Source\Win32\CxbxKrnl\EmuD3D8.cpp # End Source File # Begin Source File -SOURCE=.\Source\Win32\CxbxKrnl\EmuD3D8Conv.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\Win32\CxbxKrnl\EmuD3D8PushBuffer.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\Win32\CxbxKrnl\EmuD3D8VertexShader.cpp -# End Source File -# Begin Source File - SOURCE=.\Source\Win32\CxbxKrnl\EmuDInput.cpp # End Source File # Begin Source File diff --git a/Include/Win32/CxbxKrnl/EmuD3D8.h b/Include/Win32/CxbxKrnl/EmuD3D8.h index 80e3c37c1..0f166d13f 100644 --- a/Include/Win32/CxbxKrnl/EmuD3D8.h +++ b/Include/Win32/CxbxKrnl/EmuD3D8.h @@ -34,21 +34,14 @@ #ifndef EMUD3D8_H #define EMUD3D8_H +#include "EmuD3D8Types.h" + #include "Xbe.h" - -#undef FIELD_OFFSET // prevent macro redefinition warnings -#include - -#define DIRECT3D_VERSION 0x0800 -#include -#include -#include +#include "Emu.h" #define DIRECTDRAW_VERSION 0x0700 #include -#include "Emu.h" - // initialize direct3d extern VOID EmuD3DInit(Xbe::Header *XbeHeader, uint32 XbeHeaderSize); @@ -58,296 +51,13 @@ extern VOID EmuD3DCleanup(); // is this texture linear? extern GUID hRefGUID_bTexIsLinear; -// TODO: Fill out these enumeration tables for convienance -typedef DWORD X_D3DFORMAT; -typedef DWORD X_D3DBLENDOP; -typedef DWORD X_D3DBLEND; -typedef DWORD X_D3DCMPFUNC; -typedef DWORD X_D3DFILLMODE; -typedef DWORD X_D3DPRIMITIVETYPE; -typedef DWORD X_D3DTEXTURESTAGESTATETYPE; - -// NOTE: HACK: These enumerations are not equivalent when > 7! -typedef D3DRESOURCETYPE X_D3DRESOURCETYPE; - -// ****************************************************************** -// * X_D3DDISPLAYMODE -// ****************************************************************** -typedef struct _X_D3DDISPLAYMODE -{ - UINT Width; - UINT Height; - UINT RefreshRate; - DWORD Flags; - X_D3DFORMAT Format; -} -X_D3DDISPLAYMODE; - -// ****************************************************************** -// * X_D3DSURFACEDESC -// ****************************************************************** -typedef struct _X_D3DSURFACE_DESC -{ - X_D3DFORMAT Format; - X_D3DRESOURCETYPE Type; - DWORD Usage; - UINT Size; - D3DMULTISAMPLE_TYPE MultiSampleType; - UINT Width; - UINT Height; -} -X_D3DSURFACE_DESC; - -// ****************************************************************** -// * X_D3DPRESENT_PARAMETERS -// ****************************************************************** -typedef struct _X_D3DPRESENT_PARAMETERS -{ - UINT BackBufferWidth; - UINT BackBufferHeight; - X_D3DFORMAT BackBufferFormat; - UINT BackBufferCount; - D3DMULTISAMPLE_TYPE MultiSampleType; - D3DSWAPEFFECT SwapEffect; - HWND hDeviceWindow; - BOOL Windowed; - BOOL EnableAutoDepthStencil; - X_D3DFORMAT AutoDepthStencilFormat; - DWORD Flags; - UINT FullScreen_RefreshRateInHz; - UINT FullScreen_PresentationInterval; - IDirect3DSurface8 *BufferSurfaces[3]; - IDirect3DSurface8 *DepthStencilSurface; -} -X_D3DPRESENT_PARAMETERS; - -// ****************************************************************** -// * X_D3DVertexShader -// ****************************************************************** -struct X_D3DVertexShader -{ - union - { - DWORD UnknownA; - DWORD Handle; - }; - - DWORD UnknownB; - DWORD Flags; - DWORD UnknownC[0x59]; -}; - -// ****************************************************************** -// * X_D3DResource -// ****************************************************************** -struct X_D3DResource -{ - DWORD Common; - DWORD Data; - - union - { - DWORD Lock; - IDirect3DResource8 *EmuResource8; - IDirect3DBaseTexture8 *EmuBaseTexture8; - IDirect3DTexture8 *EmuTexture8; - IDirect3DVolumeTexture8 *EmuVolumeTexture8; - IDirect3DCubeTexture8 *EmuCubeTexture8; - IDirect3DSurface8 *EmuSurface8; - IDirect3DVertexBuffer8 *EmuVertexBuffer8; - IDirect3DIndexBuffer8 *EmuIndexBuffer8; - }; -}; - -// d3d resource "common" masks -#define X_D3DCOMMON_REFCOUNT_MASK 0x0000FFFF -#define X_D3DCOMMON_TYPE_MASK 0x00070000 -#define X_D3DCOMMON_TYPE_SHIFT 16 -#define X_D3DCOMMON_TYPE_VERTEXBUFFER 0x00000000 -#define X_D3DCOMMON_TYPE_INDEXBUFFER 0x00010000 -#define X_D3DCOMMON_TYPE_PUSHBUFFER 0x00020000 -#define X_D3DCOMMON_TYPE_PALETTE 0x00030000 -#define X_D3DCOMMON_TYPE_TEXTURE 0x00040000 -#define X_D3DCOMMON_TYPE_SURFACE 0x00050000 -#define X_D3DCOMMON_TYPE_FIXUP 0x00060000 -#define X_D3DCOMMON_INTREFCOUNT_MASK 0x00780000 -#define X_D3DCOMMON_INTREFCOUNT_SHIFT 19 -#define X_D3DCOMMON_D3DCREATED 0x01000000 -#define X_D3DCOMMON_UNUSED_MASK 0xFE000000 -#define X_D3DCOMMON_UNUSED_SHIFT 25 - -// special resource data flags -#define X_D3DRESOURCE_DATA_FLAG_SURFACE 0xEFFFFFFF - -// special resource lock flags -#define X_D3DRESOURCE_LOCK_FLAG_NOSIZE 0xEFFFFFFF - -// ****************************************************************** -// * X_D3DVertexBuffer -// ****************************************************************** -struct X_D3DVertexBuffer : public X_D3DResource -{ - -}; - -// ****************************************************************** -// * X_D3DIndexBuffer -// ****************************************************************** -struct X_D3DIndexBuffer : public X_D3DResource -{ - -}; - -// ****************************************************************** -// * X_D3DPushBuffer -// ****************************************************************** -struct X_D3DPushBuffer : public X_D3DResource -{ - ULONG Size; - ULONG AllocationSize; -}; - -// ****************************************************************** -// * X_D3DPalette -// ****************************************************************** -struct X_D3DPalette : public X_D3DResource -{ -}; - -// ****************************************************************** -// * X_D3DPALETTESIZE -// ****************************************************************** -typedef enum _X_D3DPALETTESIZE -{ - D3DPALETTE_256 = 0, - D3DPALETTE_128 = 1, - D3DPALETTE_64 = 2, - D3DPALETTE_32 = 3, - D3DPALETTE_MAX = 4, - D3DPALETTE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ -} -X_D3DPALETTESIZE; - -// ****************************************************************** -// * X_D3DPixelContainer -// ****************************************************************** -struct X_D3DPixelContainer : public X_D3DResource -{ - X_D3DFORMAT Format; - DWORD Size; -}; - -// pixel container "format" masks -#define X_D3DFORMAT_RESERVED1_MASK 0x00000003 // Must be zero -#define X_D3DFORMAT_DMACHANNEL_MASK 0x00000003 -#define X_D3DFORMAT_DMACHANNEL_A 0x00000001 // DMA channel A - the default for all system memory -#define X_D3DFORMAT_DMACHANNEL_B 0x00000002 // DMA channel B - unused -#define X_D3DFORMAT_CUBEMAP 0x00000004 // Set if the texture if a cube map -#define X_D3DFORMAT_BORDERSOURCE_COLOR 0x00000008 -#define X_D3DFORMAT_DIMENSION_MASK 0x000000F0 // # of dimensions -#define X_D3DFORMAT_DIMENSION_SHIFT 4 -#define X_D3DFORMAT_FORMAT_MASK 0x0000FF00 -#define X_D3DFORMAT_FORMAT_SHIFT 8 -#define X_D3DFORMAT_MIPMAP_MASK 0x000F0000 -#define X_D3DFORMAT_MIPMAP_SHIFT 16 -#define X_D3DFORMAT_USIZE_MASK 0x00F00000 // Log 2 of the U size of the base texture -#define X_D3DFORMAT_USIZE_SHIFT 20 -#define X_D3DFORMAT_VSIZE_MASK 0x0F000000 // Log 2 of the V size of the base texture -#define X_D3DFORMAT_VSIZE_SHIFT 24 -#define X_D3DFORMAT_PSIZE_MASK 0xF0000000 // Log 2 of the P size of the base texture -#define X_D3DFORMAT_PSIZE_SHIFT 28 - -// pixel container "size" masks -#define X_D3DSIZE_WIDTH_MASK 0x00000FFF // Width (Texels - 1) -#define X_D3DSIZE_HEIGHT_MASK 0x00FFF000 // Height (Texels - 1) -#define X_D3DSIZE_HEIGHT_SHIFT 12 -#define X_D3DSIZE_PITCH_MASK 0xFF000000 // Pitch / 64 - 1 -#define X_D3DSIZE_PITCH_SHIFT 24 - -// ****************************************************************** -// * X_D3DBaseTexture -// ****************************************************************** -struct X_D3DBaseTexture : public X_D3DPixelContainer -{ - -}; - -// ****************************************************************** -// * X_D3DTexture -// ****************************************************************** -struct X_D3DTexture : public X_D3DBaseTexture -{ - -}; - -// ****************************************************************** -// * X_D3DVolumeTexture -// ****************************************************************** -struct X_D3DVolumeTexture : public X_D3DBaseTexture -{ - -}; - -// ****************************************************************** -// * X_D3DCubeTexture -// ****************************************************************** -struct X_D3DCubeTexture : public X_D3DBaseTexture -{ - -}; - -// ****************************************************************** -// * X_D3DSurface -// ****************************************************************** -struct X_D3DSurface : public X_D3DPixelContainer -{ - -}; - -// ****************************************************************** -// * X_D3DTILE -// ****************************************************************** -struct X_D3DTILE -{ - DWORD Flags; - PVOID pMemory; - DWORD Size; - DWORD Pitch; - DWORD ZStartTag; - DWORD ZOffset; -}; - -// ****************************************************************** -// * D3DVBLANKDATA -// ****************************************************************** -typedef struct _D3DVBLANKDATA -{ - DWORD VBlank; - DWORD Swap; - DWORD Flags; -} -D3DVBLANKDATA; - -// ****************************************************************** -// * D3DVBLANKCALLBACK -// ****************************************************************** -typedef void (__cdecl * D3DVBLANKCALLBACK)(D3DVBLANKDATA *pData); - -// ****************************************************************** -// * EmuD3DTileCache (8 Tiles Max) -// ****************************************************************** +// EmuD3DTileCache (8 tiles maximum) extern X_D3DTILE EmuD3DTileCache[0x08]; -// ****************************************************************** -// * EmuD3DDeferredRenderState -// ****************************************************************** -#define X_D3DRS_UNK 0x7fffffff +// EmuD3DDeferredRenderState extern DWORD *EmuD3DDeferredRenderState; -// ****************************************************************** -// * EmuD3DDeferredTextureState -// ****************************************************************** -#define X_D3DTSS_UNK 0x7fffffff +// EmuD3DDeferredTextureState extern DWORD *EmuD3DDeferredTextureState; // ****************************************************************** diff --git a/Include/Win32/CxbxKrnl/EmuD3D8Conv.h b/Include/Win32/CxbxKrnl/EmuD3D8/Convert.h similarity index 53% rename from Include/Win32/CxbxKrnl/EmuD3D8Conv.h rename to Include/Win32/CxbxKrnl/EmuD3D8/Convert.h index 99e2b31e1..7a2e1cd98 100644 --- a/Include/Win32/CxbxKrnl/EmuD3D8Conv.h +++ b/Include/Win32/CxbxKrnl/EmuD3D8/Convert.h @@ -7,7 +7,7 @@ // * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo, // * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm, // * -// * Cxbx->Win32->CxbxKrnl->EmuD3D8Conv.h +// * Cxbx->Win32->CxbxKrnl->EmuD3D8->Convert.h // * // * This file is part of the Cxbx project. // * @@ -31,132 +31,18 @@ // * All rights reserved // * // ****************************************************************** -#ifndef EMUD3D8CONV_H -#define EMUD3D8CONV_H - -// fixup xbox extensions to be compatible with PC direct3d -extern UINT EmuFixupVerticesA -( - DWORD PrimitiveType, - UINT &PrimitiveCount, - XTL::IDirect3DVertexBuffer8 *&pOrigVertexBuffer8, - XTL::IDirect3DVertexBuffer8 *&pHackVertexBuffer8, - UINT dwOffset, - PVOID pVertexStreamZeroData, - UINT uiVertexStreamZeroStride, - PVOID *ppNewVertexStreamZeroData -); - -// fixup xbox extensions to be compatible with PC direct3d -extern VOID EmuFixupVerticesB -( - UINT nStride, - XTL::IDirect3DVertexBuffer8 *&pOrigVertexBuffer8, - XTL::IDirect3DVertexBuffer8 *&pHackVertexBuffer8 -); - -// table used to vertex->primitive count conversion -extern UINT EmuD3DVertexToPrimitive[11][2]; - -// conversion table for xbox->pc primitive types -extern D3DPRIMITIVETYPE EmuPrimitiveTypeLookup[]; +#ifndef CONVERT_H +#define CONVERT_H // simple render state encoding lookup table #define X_D3DRSSE_UNK 0x7fffffff extern CONST DWORD EmuD3DRenderStateSimpleEncoded[174]; // convert from xbox to pc color formats -inline D3DFORMAT EmuXB2PC_D3DFormat(X_D3DFORMAT Format) -{ - switch(Format) - { - case 0x00: // Swizzled (X_D3DFMT_L8) - case 0x01: // Swizzled (X_D3DFMT_AL8) // NOTE: Hack: Alpha ignored, basically - return D3DFMT_L8; - - case 0x02: // Swizzled (X_D3DFMT_A1R5G5B5) - return D3DFMT_A1R5G5B5; - - case 0x1A: // Swizzled (X_D3DFMT_A8L8) - return D3DFMT_R5G6B5; // NOTE: HACK: Totally and utterly wrong :) - - case 0x1D: // Linear (X_D3DFMT_LIN_A4R4G4B4) - case 0x04: // Swizzled (X_D3DFMT_A4R4G4B4) - return D3DFMT_A4R4G4B4; - - case 0x11: // Linear (X_D3DFMT_LIN_R5G6B5) - case 0x05: // Swizzled (X_D3DFMT_R5G6B5) - return D3DFMT_R5G6B5; - - case 0x12: // Linear (X_D3DFMT_LIN_A8R8G8B8) - case 0x06: // Swizzled (X_D3DFMT_A8R8G8B8) - return D3DFMT_A8R8G8B8; - - case 0x3F: // Linear (X_D3DFMT_LIN_A8B8G8R8) - return D3DFMT_A8R8G8B8; // NOTE: HACK: R<->B Swapped! - - case 0x1E: // Linear (X_D3DFMT_LIN_X8R8G8B8) - case 0x07: // Swizzled (X_D3DFMT_X8R8G8B8) - return D3DFMT_X8R8G8B8; - - case 0x0B: // Swizzled (X_D3DFMT_P8) - return D3DFMT_P8; - - case 0x0C: // Compressed (X_D3DFMT_DXT1) - return D3DFMT_DXT1; - - case 0x0E: // Compressed (X_D3DFMT_DXT2) - return D3DFMT_DXT2; - - case 0x0F: // Compressed (X_D3DFMT_DXT3) - return D3DFMT_DXT3; - - case 0x24: // Swizzled (X_D3DFMT_YUV2) - return D3DFMT_YUY2; - - case 0x2E: // Linear (X_D3DFMT_LIN_D24S8) - case 0x2A: // Swizzled (X_D3DFMT_D24S8) - return D3DFMT_D24S8; - - case 0x2B: // Swizzled (X_D3DFMT_F24S8) - return D3DFMT_D24S8; // NOTE: Hack!! PC does not have D3DFMT_F24S8 (Float vs Int) - - case 0x30: // Linear (X_D3DFMT_LIN_D16) - case 0x2C: // Swizzled (X_D3DFMT_D16) - return D3DFMT_D16; - - case 0x28: // Swizzled (X_D3DFMT_V8U8) - return D3DFMT_V8U8; - } - - EmuCleanup("EmuXB2PC_D3DFormat: Unknown Format (0x%.08X)", Format); - - return (D3DFORMAT)Format; -} +extern D3DFORMAT EmuXB2PC_D3DFormat(X_D3DFORMAT Format); // convert from pc to xbox color formats -inline X_D3DFORMAT EmuPC2XB_D3DFormat(D3DFORMAT Format) -{ - switch(Format) - { - case D3DFMT_YUY2: - return 0x24; - case D3DFMT_R5G6B5: - return 0x05; - case D3DFMT_D24S8: - return 0x2A; - case D3DFMT_X8R8G8B8: -// return 0x1E; // Linear (X_D3DFMT_LIN_X8R8G8B8) - return 0x07; - case D3DFMT_A8R8G8B8: -// return 0x12; // Linear (X_D3DFMT_LIN_A8R8G8B8) - return 0x06; - } - - EmuCleanup("EmuPC2XB_D3DFormat: Unknown Format (%d)", Format); - - return Format; -} +extern X_D3DFORMAT EmuPC2XB_D3DFormat(D3DFORMAT Format); /** // convert from pc to xbox texture transform state types (unnecessary so far) @@ -224,6 +110,9 @@ inline D3DFILLMODE EmuXB2PC_D3DFILLMODE(X_D3DFILLMODE Value) return (D3DFILLMODE)((Value & 0xF) + 1); } +// table used for vertex->primitive count conversion +extern UINT EmuD3DVertexToPrimitive[11][2]; + // convert from vertex count to primitive count (Xbox) inline int EmuD3DVertex2PrimitiveCount(int PrimitiveType, int VertexCount) { @@ -236,7 +125,10 @@ inline int EmuD3DPrimitive2VertexCount(int PrimitiveType, int PrimitiveCount) return (((PrimitiveCount)*EmuD3DVertexToPrimitive[PrimitiveType][0])+EmuD3DVertexToPrimitive[PrimitiveType][1]); } -// convert from xbox to d3d primitive type +// conversion table for xbox->pc primitive types +extern D3DPRIMITIVETYPE EmuPrimitiveTypeLookup[]; + +// convert xbox->pc primitive type inline D3DPRIMITIVETYPE EmuPrimitiveType(X_D3DPRIMITIVETYPE PrimitiveType) { if((DWORD)PrimitiveType == 0x7FFFFFFF) diff --git a/Include/Win32/CxbxKrnl/EmuD3D8PushBuffer.h b/Include/Win32/CxbxKrnl/EmuD3D8/PushBuffer.h similarity index 93% rename from Include/Win32/CxbxKrnl/EmuD3D8PushBuffer.h rename to Include/Win32/CxbxKrnl/EmuD3D8/PushBuffer.h index 6200689b9..1c990fb2d 100644 --- a/Include/Win32/CxbxKrnl/EmuD3D8PushBuffer.h +++ b/Include/Win32/CxbxKrnl/EmuD3D8/PushBuffer.h @@ -7,7 +7,7 @@ // * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo, // * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm, // * -// * Cxbx->Win32->CxbxKrnl->EmuD3D8PushBuffer.h +// * Cxbx->Win32->CxbxKrnl->EmuD3D8->PushBuffer.h // * // * This file is part of the Cxbx project. // * @@ -31,8 +31,8 @@ // * All rights reserved // * // ****************************************************************** -#ifndef EMUD3D8PUSHBUFFER_H -#define EMUD3D8PUSHBUFFER_H +#ifndef PUSHBUFFER_H +#define PUSHBUFFER_H // emulate the execution of an xbox d3d pushbuffer extern void EmuExecutePushBuffer diff --git a/Include/Win32/CxbxKrnl/EmuD3D8/VertexBuffer.h b/Include/Win32/CxbxKrnl/EmuD3D8/VertexBuffer.h new file mode 100644 index 000000000..7df6c3dc8 --- /dev/null +++ b/Include/Win32/CxbxKrnl/EmuD3D8/VertexBuffer.h @@ -0,0 +1,58 @@ +// ****************************************************************** +// * +// * .,-::::: .,:: .::::::::. .,:: .: +// * ,;;;'````' `;;;, .,;; ;;;'';;' `;;;, .,;; +// * [[[ '[[,,[[' [[[__[[\. '[[,,[[' +// * $$$ Y$$$P $$""""Y$$ Y$$$P +// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo, +// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm, +// * +// * Cxbx->Win32->CxbxKrnl->EmuD3D8->VertexBuffer.h +// * +// * 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 +// * +// * All rights reserved +// * +// ****************************************************************** +#ifndef VERTEXBUFFER_H +#define VERTEXBUFFER_H + +// fixup xbox extensions to be compatible with PC direct3d +extern UINT EmuFixupVerticesA +( + DWORD PrimitiveType, + UINT &PrimitiveCount, + XTL::IDirect3DVertexBuffer8 *&pOrigVertexBuffer8, + XTL::IDirect3DVertexBuffer8 *&pHackVertexBuffer8, + UINT dwOffset, + PVOID pVertexStreamZeroData, + UINT uiVertexStreamZeroStride, + PVOID *ppNewVertexStreamZeroData +); + +// fixup xbox extensions to be compatible with PC direct3d +extern VOID EmuFixupVerticesB +( + UINT nStride, + XTL::IDirect3DVertexBuffer8 *&pOrigVertexBuffer8, + XTL::IDirect3DVertexBuffer8 *&pHackVertexBuffer8 +); + +#endif \ No newline at end of file diff --git a/Include/Win32/CxbxKrnl/EmuD3D8VertexShader.h b/Include/Win32/CxbxKrnl/EmuD3D8/VertexShader.h similarity index 94% rename from Include/Win32/CxbxKrnl/EmuD3D8VertexShader.h rename to Include/Win32/CxbxKrnl/EmuD3D8/VertexShader.h index 0f38cdfb4..51e5c7582 100644 --- a/Include/Win32/CxbxKrnl/EmuD3D8VertexShader.h +++ b/Include/Win32/CxbxKrnl/EmuD3D8/VertexShader.h @@ -7,7 +7,7 @@ // * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo, // * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm, // * -// * Cxbx->Win32->CxbxKrnl->EmuD3D8VertexShader.h +// * Cxbx->Win32->CxbxKrnl->EmuD3D8->VertexShader.h // * // * This file is part of the Cxbx project. // * @@ -31,8 +31,8 @@ // * All rights reserved // * // ****************************************************************** -#ifndef EMUD3D8VERTEXSHADER_H -#define EMUD3D8VERTEXSHADER_H +#ifndef VERTEXSHADER_H +#define VERTEXSHADER_H // nv2a microcode header typedef struct _NV2A_HEADER @@ -63,4 +63,4 @@ extern void EmuRecompileVSHFunction DWORD **pRecompiled ); -#endif \ No newline at end of file +#endif diff --git a/Include/Win32/CxbxKrnl/EmuD3D8Types.h b/Include/Win32/CxbxKrnl/EmuD3D8Types.h new file mode 100644 index 000000000..cfcad5894 --- /dev/null +++ b/Include/Win32/CxbxKrnl/EmuD3D8Types.h @@ -0,0 +1,267 @@ +// ****************************************************************** +// * +// * .,-::::: .,:: .::::::::. .,:: .: +// * ,;;;'````' `;;;, .,;; ;;;'';;' `;;;, .,;; +// * [[[ '[[,,[[' [[[__[[\. '[[,,[[' +// * $$$ Y$$$P $$""""Y$$ Y$$$P +// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo, +// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm, +// * +// * Cxbx->Win32->CxbxKrnl->EmuD3D8Types.h +// * +// * 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 +// * +// * All rights reserved +// * +// ****************************************************************** +#ifndef EMUD3D8TYPES_H +#define EMUD3D8TYPES_H + +// include direct3d 8x headers +#define DIRECT3D_VERSION 0x0800 +#include +#include +#include + +// TODO: fill out these enumeration tables for convienance +typedef DWORD X_D3DFORMAT; +typedef DWORD X_D3DBLENDOP; +typedef DWORD X_D3DBLEND; +typedef DWORD X_D3DCMPFUNC; +typedef DWORD X_D3DFILLMODE; +typedef DWORD X_D3DPRIMITIVETYPE; +typedef DWORD X_D3DTEXTURESTAGESTATETYPE; + +// TODO: these enumerations are not equivalent when > 7! +typedef D3DRESOURCETYPE X_D3DRESOURCETYPE; + +typedef struct _X_D3DDISPLAYMODE +{ + UINT Width; + UINT Height; + UINT RefreshRate; + DWORD Flags; + X_D3DFORMAT Format; +} +X_D3DDISPLAYMODE; + +typedef struct _X_D3DSURFACE_DESC +{ + X_D3DFORMAT Format; + X_D3DRESOURCETYPE Type; + DWORD Usage; + UINT Size; + D3DMULTISAMPLE_TYPE MultiSampleType; + UINT Width; + UINT Height; +} +X_D3DSURFACE_DESC; + +typedef struct _X_D3DPRESENT_PARAMETERS +{ + UINT BackBufferWidth; + UINT BackBufferHeight; + X_D3DFORMAT BackBufferFormat; + UINT BackBufferCount; + D3DMULTISAMPLE_TYPE MultiSampleType; + D3DSWAPEFFECT SwapEffect; + HWND hDeviceWindow; + BOOL Windowed; + BOOL EnableAutoDepthStencil; + X_D3DFORMAT AutoDepthStencilFormat; + DWORD Flags; + UINT FullScreen_RefreshRateInHz; + UINT FullScreen_PresentationInterval; + IDirect3DSurface8 *BufferSurfaces[3]; + IDirect3DSurface8 *DepthStencilSurface; +} +X_D3DPRESENT_PARAMETERS; + +struct X_D3DVertexShader +{ + union + { + DWORD UnknownA; + DWORD Handle; + }; + + DWORD UnknownB; + DWORD Flags; + DWORD UnknownC[0x59]; +}; + +struct X_D3DResource +{ + DWORD Common; + DWORD Data; + + union + { + DWORD Lock; + IDirect3DResource8 *EmuResource8; + IDirect3DBaseTexture8 *EmuBaseTexture8; + IDirect3DTexture8 *EmuTexture8; + IDirect3DVolumeTexture8 *EmuVolumeTexture8; + IDirect3DCubeTexture8 *EmuCubeTexture8; + IDirect3DSurface8 *EmuSurface8; + IDirect3DVertexBuffer8 *EmuVertexBuffer8; + IDirect3DIndexBuffer8 *EmuIndexBuffer8; + }; +}; + +// d3d resource "common" masks +#define X_D3DCOMMON_REFCOUNT_MASK 0x0000FFFF +#define X_D3DCOMMON_TYPE_MASK 0x00070000 +#define X_D3DCOMMON_TYPE_SHIFT 16 +#define X_D3DCOMMON_TYPE_VERTEXBUFFER 0x00000000 +#define X_D3DCOMMON_TYPE_INDEXBUFFER 0x00010000 +#define X_D3DCOMMON_TYPE_PUSHBUFFER 0x00020000 +#define X_D3DCOMMON_TYPE_PALETTE 0x00030000 +#define X_D3DCOMMON_TYPE_TEXTURE 0x00040000 +#define X_D3DCOMMON_TYPE_SURFACE 0x00050000 +#define X_D3DCOMMON_TYPE_FIXUP 0x00060000 +#define X_D3DCOMMON_INTREFCOUNT_MASK 0x00780000 +#define X_D3DCOMMON_INTREFCOUNT_SHIFT 19 +#define X_D3DCOMMON_D3DCREATED 0x01000000 +#define X_D3DCOMMON_UNUSED_MASK 0xFE000000 +#define X_D3DCOMMON_UNUSED_SHIFT 25 + +// special resource data flags +#define X_D3DRESOURCE_DATA_FLAG_SURFACE 0xEFFFFFFF + +// special resource lock flags +#define X_D3DRESOURCE_LOCK_FLAG_NOSIZE 0xEFFFFFFF + +struct X_D3DVertexBuffer : public X_D3DResource +{ + +}; +struct X_D3DIndexBuffer : public X_D3DResource +{ + +}; + +struct X_D3DPushBuffer : public X_D3DResource +{ + ULONG Size; + ULONG AllocationSize; +}; + +struct X_D3DPalette : public X_D3DResource +{ +}; + +typedef enum _X_D3DPALETTESIZE +{ + D3DPALETTE_256 = 0, + D3DPALETTE_128 = 1, + D3DPALETTE_64 = 2, + D3DPALETTE_32 = 3, + D3DPALETTE_MAX = 4, + D3DPALETTE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} +X_D3DPALETTESIZE; + +struct X_D3DPixelContainer : public X_D3DResource +{ + X_D3DFORMAT Format; + DWORD Size; +}; + +// pixel container "format" masks +#define X_D3DFORMAT_RESERVED1_MASK 0x00000003 // Must be zero +#define X_D3DFORMAT_DMACHANNEL_MASK 0x00000003 +#define X_D3DFORMAT_DMACHANNEL_A 0x00000001 // DMA channel A - the default for all system memory +#define X_D3DFORMAT_DMACHANNEL_B 0x00000002 // DMA channel B - unused +#define X_D3DFORMAT_CUBEMAP 0x00000004 // Set if the texture if a cube map +#define X_D3DFORMAT_BORDERSOURCE_COLOR 0x00000008 +#define X_D3DFORMAT_DIMENSION_MASK 0x000000F0 // # of dimensions +#define X_D3DFORMAT_DIMENSION_SHIFT 4 +#define X_D3DFORMAT_FORMAT_MASK 0x0000FF00 +#define X_D3DFORMAT_FORMAT_SHIFT 8 +#define X_D3DFORMAT_MIPMAP_MASK 0x000F0000 +#define X_D3DFORMAT_MIPMAP_SHIFT 16 +#define X_D3DFORMAT_USIZE_MASK 0x00F00000 // Log 2 of the U size of the base texture +#define X_D3DFORMAT_USIZE_SHIFT 20 +#define X_D3DFORMAT_VSIZE_MASK 0x0F000000 // Log 2 of the V size of the base texture +#define X_D3DFORMAT_VSIZE_SHIFT 24 +#define X_D3DFORMAT_PSIZE_MASK 0xF0000000 // Log 2 of the P size of the base texture +#define X_D3DFORMAT_PSIZE_SHIFT 28 + +// pixel container "size" masks +#define X_D3DSIZE_WIDTH_MASK 0x00000FFF // Width (Texels - 1) +#define X_D3DSIZE_HEIGHT_MASK 0x00FFF000 // Height (Texels - 1) +#define X_D3DSIZE_HEIGHT_SHIFT 12 +#define X_D3DSIZE_PITCH_MASK 0xFF000000 // Pitch / 64 - 1 +#define X_D3DSIZE_PITCH_SHIFT 24 + +struct X_D3DBaseTexture : public X_D3DPixelContainer +{ + +}; + +struct X_D3DTexture : public X_D3DBaseTexture +{ + +}; + +struct X_D3DVolumeTexture : public X_D3DBaseTexture +{ + +}; + +struct X_D3DCubeTexture : public X_D3DBaseTexture +{ + +}; + +struct X_D3DSurface : public X_D3DPixelContainer +{ + +}; + +struct X_D3DTILE +{ + DWORD Flags; + PVOID pMemory; + DWORD Size; + DWORD Pitch; + DWORD ZStartTag; + DWORD ZOffset; +}; + +typedef struct _D3DVBLANKDATA +{ + DWORD VBlank; + DWORD Swap; + DWORD Flags; +} +D3DVBLANKDATA; + +// D3DVBLANKCALLBACK +typedef void (__cdecl * D3DVBLANKCALLBACK)(D3DVBLANKDATA *pData); + +// deferred render state "unknown" flag +#define X_D3DRS_UNK 0x7fffffff + +// deferred texture stage state "unknown" flag +#define X_D3DTSS_UNK 0x7fffffff + +#endif diff --git a/Include/Win32/CxbxKrnl/EmuXTL.h b/Include/Win32/CxbxKrnl/EmuXTL.h index eb28ffe3a..4166b7885 100644 --- a/Include/Win32/CxbxKrnl/EmuXTL.h +++ b/Include/Win32/CxbxKrnl/EmuXTL.h @@ -36,9 +36,10 @@ #include "EmuXapi.h" #include "EmuD3D8.h" -#include "EmuD3D8Conv.h" -#include "EmuD3D8PushBuffer.h" -#include "EmuD3D8VertexShader.h" +#include "EmuD3D8\Convert.h" +#include "EmuD3D8\VertexBuffer.h" +#include "EmuD3D8\PushBuffer.h" +#include "EmuD3D8\VertexShader.h" #include "EmuDInput.h" #include "EmuDSound.h" #include "EmuXOnline.h" diff --git a/Source/Win32/CxbxKrnl/Emu.cpp b/Source/Win32/CxbxKrnl/Emu.cpp index 22e4b2db5..372129be4 100644 --- a/Source/Win32/CxbxKrnl/Emu.cpp +++ b/Source/Win32/CxbxKrnl/Emu.cpp @@ -32,7 +32,7 @@ // * // ****************************************************************** #define _CXBXKRNL_INTERNAL -#define _XBOXKRNL_LOCAL_ +#define _XBOXKRNL_DEFEXTRN_ // prevent name collisions namespace xboxkrnl diff --git a/Source/Win32/CxbxKrnl/EmuD3D8.cpp b/Source/Win32/CxbxKrnl/EmuD3D8.cpp index 3d6e1a161..8606750d8 100644 --- a/Source/Win32/CxbxKrnl/EmuD3D8.cpp +++ b/Source/Win32/CxbxKrnl/EmuD3D8.cpp @@ -32,7 +32,7 @@ // * // ****************************************************************** #define _CXBXKRNL_INTERNAL -#define _XBOXKRNL_LOCAL_ +#define _XBOXKRNL_DEFEXTRN_ // prevent name collisions namespace xboxkrnl diff --git a/Source/Win32/CxbxKrnl/EmuD3D8Conv.cpp b/Source/Win32/CxbxKrnl/EmuD3D8/Convert.cpp similarity index 99% rename from Source/Win32/CxbxKrnl/EmuD3D8Conv.cpp rename to Source/Win32/CxbxKrnl/EmuD3D8/Convert.cpp index b4620fe9d..a48e82f85 100644 --- a/Source/Win32/CxbxKrnl/EmuD3D8Conv.cpp +++ b/Source/Win32/CxbxKrnl/EmuD3D8/Convert.cpp @@ -7,7 +7,7 @@ // * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo, // * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm, // * -// * Cxbx->Win32->CxbxKrnl->EmuD3D8Conv.cpp +// * Cxbx->Win32->CxbxKrnl->EmuD3D8->Convert.cpp // * // * This file is part of the Cxbx project. // * @@ -32,7 +32,7 @@ // * // ****************************************************************** #define _CXBXKRNL_INTERNAL -#define _XBOXKRNL_LOCAL_ +#define _XBOXKRNL_DEFEXTRN_ // prevent name collisions namespace xboxkrnl diff --git a/Source/Win32/CxbxKrnl/EmuD3D8PushBuffer.cpp b/Source/Win32/CxbxKrnl/EmuD3D8/PushBuffer.cpp similarity index 96% rename from Source/Win32/CxbxKrnl/EmuD3D8PushBuffer.cpp rename to Source/Win32/CxbxKrnl/EmuD3D8/PushBuffer.cpp index b1d0d50ec..1af930789 100644 --- a/Source/Win32/CxbxKrnl/EmuD3D8PushBuffer.cpp +++ b/Source/Win32/CxbxKrnl/EmuD3D8/PushBuffer.cpp @@ -7,7 +7,7 @@ // * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo, // * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm, // * -// * Cxbx->Win32->CxbxKrnl->EmuD3D8PushBuffer.cpp +// * Cxbx->Win32->CxbxKrnl->EmuD3D->PushBuffer.cpp // * // * This file is part of the Cxbx project. // * @@ -32,17 +32,9 @@ // * // ****************************************************************** #define _CXBXKRNL_INTERNAL -#define _XBOXKRNL_LOCAL_ - -// prevent name collisions -namespace xboxkrnl -{ - #include -}; +#define _XBOXKRNL_DEFEXTRN_ #include "Emu.h" -#include "EmuFS.h" -#include "EmuShared.h" // prevent name collisions namespace XTL @@ -179,4 +171,4 @@ void XTL::EmuExecutePushBuffer break; } } -} \ No newline at end of file +} diff --git a/Source/Win32/CxbxKrnl/EmuD3D8/VertexBuffer.cpp b/Source/Win32/CxbxKrnl/EmuD3D8/VertexBuffer.cpp new file mode 100644 index 000000000..db924b599 --- /dev/null +++ b/Source/Win32/CxbxKrnl/EmuD3D8/VertexBuffer.cpp @@ -0,0 +1,233 @@ +// ****************************************************************** +// * +// * .,-::::: .,:: .::::::::. .,:: .: +// * ,;;;'````' `;;;, .,;; ;;;'';;' `;;;, .,;; +// * [[[ '[[,,[[' [[[__[[\. '[[,,[[' +// * $$$ Y$$$P $$""""Y$$ Y$$$P +// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo, +// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm, +// * +// * Cxbx->Win32->CxbxKrnl->EmuD3D8->VertexBuffer.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 +// * +// * All rights reserved +// * +// ****************************************************************** +#define _CXBXKRNL_INTERNAL +#define _XBOXKRNL_DEFEXTRN_ + +#include "Emu.h" + +// prevent name collisions +namespace XTL +{ + #include "EmuXTL.h" +}; + +extern XTL::LPDIRECT3DDEVICE8 g_pD3DDevice8; // Direct3D8 Device + +// fixup xbox extensions to be compatible with PC direct3d +UINT XTL::EmuFixupVerticesA +( + DWORD PrimitiveType, + UINT &PrimitiveCount, + XTL::IDirect3DVertexBuffer8 *&pOrigVertexBuffer8, + XTL::IDirect3DVertexBuffer8 *&pHackVertexBuffer8, + UINT dwOffset, + PVOID pVertexStreamZeroData, + UINT uiVertexStreamZeroStride, + PVOID *ppNewVertexStreamZeroData +) +{ + // only quad and listloop are supported right now + if(PrimitiveType != 8 && PrimitiveType != 3) + return -1; + + // stride of this stream source + UINT uiStride = 0; + + // sizes of our part in the vertex buffer + DWORD dwOriginalSize = 0; + DWORD dwNewSize = 0; + + // sizes with the rest of the buffer + DWORD dwOriginalSizeWR = 0; + DWORD dwNewSizeWR = 0; + + // vertex data arrays + BYTE *pOrigVertexData = 0; + BYTE *pHackVertexData = 0; + + if(pVertexStreamZeroData == 0) + { + g_pD3DDevice8->GetStreamSource(0, &pOrigVertexBuffer8, &uiStride); + + if(PrimitiveType == 8) // Quad + { + PrimitiveCount *= 2; + + // This is a list of sqares/rectangles, so we convert it to a list of triangles + dwOriginalSize = PrimitiveCount*uiStride*2; + dwNewSize = PrimitiveCount*uiStride*3; + } + else if(PrimitiveType == 3) // LineLoop + { + PrimitiveCount += 1; + + // We will add exactly one more line + dwOriginalSize = PrimitiveCount*uiStride; + dwNewSize = PrimitiveCount*uiStride + uiStride; + } + + // Retrieve the original buffer size + { + XTL::D3DVERTEXBUFFER_DESC Desc; + + if(FAILED(pOrigVertexBuffer8->GetDesc(&Desc))) + EmuCleanup("Could not retrieve buffer size"); + + // Here we save the full buffer size + dwOriginalSizeWR = Desc.Size; + + // So we can now calculate the size of the rest (dwOriginalSizeWR - dwOriginalSize) and + // add it to our new calculated size of the patched buffer + dwNewSizeWR = dwNewSize + dwOriginalSizeWR - dwOriginalSize; + } + + g_pD3DDevice8->CreateVertexBuffer(dwNewSizeWR, 0, 0, XTL::D3DPOOL_MANAGED, &pHackVertexBuffer8); + + if(pOrigVertexBuffer8 != 0) + pOrigVertexBuffer8->Lock(0, 0, &pOrigVertexData, 0); + + if(pHackVertexBuffer8 != 0) + pHackVertexBuffer8->Lock(0, 0, &pHackVertexData, 0); + } + else + { + uiStride = uiVertexStreamZeroStride; + + if(PrimitiveType == 8) // Quad + { + PrimitiveCount *= 2; + + // This is a list of sqares/rectangles, so we convert it to a list of triangles + dwOriginalSize = PrimitiveCount*uiStride*2; + dwNewSize = PrimitiveCount*uiStride*3; + } + else if(PrimitiveType == 3) // LineLoop + { + PrimitiveCount += 1; + + // We will add exactly one more line + dwOriginalSize = PrimitiveCount*uiStride; + dwNewSize = PrimitiveCount*uiStride + uiStride; + } + + dwOriginalSizeWR = dwOriginalSize; + dwNewSizeWR = dwNewSize; + + pHackVertexData = (uint08*)malloc(dwNewSizeWR); + pOrigVertexData = (uint08*)pVertexStreamZeroData; + + *ppNewVertexStreamZeroData = pHackVertexData; + } + + DWORD dwVertexShader = NULL; + + g_pD3DDevice8->GetVertexShader(&dwVertexShader); + + // Copy the nonmodified data + memcpy(pHackVertexData, pOrigVertexData, dwOffset); + memcpy(&pHackVertexData[dwOffset+dwNewSize], &pOrigVertexData[dwOffset+dwOriginalSize], dwOriginalSizeWR-dwOffset-dwOriginalSize); + + if(PrimitiveType == 8) // Quad + { + uint08 *pHack1 = &pHackVertexData[dwOffset+0*uiStride]; + uint08 *pHack2 = &pHackVertexData[dwOffset+3*uiStride]; + uint08 *pHack3 = &pHackVertexData[dwOffset+4*uiStride]; + uint08 *pHack4 = &pHackVertexData[dwOffset+5*uiStride]; + + uint08 *pOrig1 = &pOrigVertexData[dwOffset+0*uiStride]; + uint08 *pOrig2 = &pOrigVertexData[dwOffset+2*uiStride]; + uint08 *pOrig3 = &pOrigVertexData[dwOffset+3*uiStride]; + + for(uint32 i=0;iUnlock(); + pHackVertexBuffer8->Unlock(); + + g_pD3DDevice8->SetStreamSource(0, pHackVertexBuffer8, uiStride); + } + + return uiStride; +} + +// fixup xbox extensions to be compatible with PC direct3d +VOID XTL::EmuFixupVerticesB +( + UINT nStride, + XTL::IDirect3DVertexBuffer8 *&pOrigVertexBuffer8, + XTL::IDirect3DVertexBuffer8 *&pHackVertexBuffer8 +) +{ + if(pOrigVertexBuffer8 != 0 && pHackVertexBuffer8 != 0) + g_pD3DDevice8->SetStreamSource(0, pOrigVertexBuffer8, nStride); + + if(pOrigVertexBuffer8 != 0) + pOrigVertexBuffer8->Release(); + + if(pHackVertexBuffer8 != 0) + pHackVertexBuffer8->Release(); +} diff --git a/Source/Win32/CxbxKrnl/EmuD3D8VertexShader.cpp b/Source/Win32/CxbxKrnl/EmuD3D8/VertexShader.cpp similarity index 99% rename from Source/Win32/CxbxKrnl/EmuD3D8VertexShader.cpp rename to Source/Win32/CxbxKrnl/EmuD3D8/VertexShader.cpp index 3112d5703..93b1d1c46 100644 --- a/Source/Win32/CxbxKrnl/EmuD3D8VertexShader.cpp +++ b/Source/Win32/CxbxKrnl/EmuD3D8/VertexShader.cpp @@ -7,7 +7,7 @@ // * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo, // * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm, // * -// * Cxbx->Win32->CxbxKrnl->EmuD3D8VertexShader.cpp +// * Cxbx->Win32->CxbxKrnl->EmuD3D8->VertexShader.cpp // * // * This file is part of the Cxbx project. // * @@ -32,17 +32,9 @@ // * // ****************************************************************** #define _CXBXKRNL_INTERNAL -#define _XBOXKRNL_LOCAL_ - -// prevent name collisions -namespace xboxkrnl -{ - #include -}; +#define _XBOXKRNL_DEFEXTRN_ #include "Emu.h" -#include "EmuFS.h" -#include "EmuShared.h" // prevent name collisions namespace XTL diff --git a/Source/Win32/CxbxKrnl/EmuDInput.cpp b/Source/Win32/CxbxKrnl/EmuDInput.cpp index 0ffbeff7b..7f3979de1 100644 --- a/Source/Win32/CxbxKrnl/EmuDInput.cpp +++ b/Source/Win32/CxbxKrnl/EmuDInput.cpp @@ -32,7 +32,7 @@ // * // ****************************************************************** #define _CXBXKRNL_INTERNAL -#define _XBOXKRNL_LOCAL_ +#define _XBOXKRNL_DEFEXTRN_ #include "Emu.h" diff --git a/Source/Win32/CxbxKrnl/EmuDSound.cpp b/Source/Win32/CxbxKrnl/EmuDSound.cpp index 1f3f3e5cb..c3be98ce5 100644 --- a/Source/Win32/CxbxKrnl/EmuDSound.cpp +++ b/Source/Win32/CxbxKrnl/EmuDSound.cpp @@ -32,7 +32,7 @@ // * // ****************************************************************** #define _CXBXKRNL_INTERNAL -#define _XBOXKRNL_LOCAL_ +#define _XBOXKRNL_DEFEXTRN_ // prevent name collisions namespace xboxkrnl diff --git a/Source/Win32/CxbxKrnl/EmuFS.cpp b/Source/Win32/CxbxKrnl/EmuFS.cpp index 898a65f27..28c919cd9 100644 --- a/Source/Win32/CxbxKrnl/EmuFS.cpp +++ b/Source/Win32/CxbxKrnl/EmuFS.cpp @@ -32,7 +32,7 @@ // * // ****************************************************************** #define _CXBXKRNL_INTERNAL -#define _XBOXKRNL_LOCAL_ +#define _XBOXKRNL_DEFEXTRN_ // prevent name collisions namespace xboxkrnl diff --git a/Source/Win32/CxbxKrnl/EmuFile.cpp b/Source/Win32/CxbxKrnl/EmuFile.cpp index 9d38f27da..3259f0d18 100644 --- a/Source/Win32/CxbxKrnl/EmuFile.cpp +++ b/Source/Win32/CxbxKrnl/EmuFile.cpp @@ -32,7 +32,7 @@ // * // ****************************************************************** #define _CXBXKRNL_INTERNAL -#define _XBOXKRNL_LOCAL_ +#define _XBOXKRNL_DEFEXTRN_ #include "EmuFile.h" diff --git a/Source/Win32/CxbxKrnl/EmuKrnl.cpp b/Source/Win32/CxbxKrnl/EmuKrnl.cpp index 0db9070a1..50c9f1038 100644 --- a/Source/Win32/CxbxKrnl/EmuKrnl.cpp +++ b/Source/Win32/CxbxKrnl/EmuKrnl.cpp @@ -32,7 +32,7 @@ // * // ****************************************************************** #define _CXBXKRNL_INTERNAL -#define _XBOXKRNL_LOCAL_ +#define _XBOXKRNL_DEFEXTRN_ // prevent name collisions namespace xboxkrnl diff --git a/Source/Win32/CxbxKrnl/EmuLDT.cpp b/Source/Win32/CxbxKrnl/EmuLDT.cpp index 570388431..bf0dfffb5 100644 --- a/Source/Win32/CxbxKrnl/EmuLDT.cpp +++ b/Source/Win32/CxbxKrnl/EmuLDT.cpp @@ -32,7 +32,7 @@ // * // ****************************************************************** #define _CXBXKRNL_INTERNAL -#define _XBOXKRNL_LOCAL_ +#define _XBOXKRNL_DEFEXTRN_ #include "Cxbx.h" diff --git a/Source/Win32/CxbxKrnl/EmuNtDll.cpp b/Source/Win32/CxbxKrnl/EmuNtDll.cpp index fffa9d0e6..48d4d4396 100644 --- a/Source/Win32/CxbxKrnl/EmuNtDll.cpp +++ b/Source/Win32/CxbxKrnl/EmuNtDll.cpp @@ -32,7 +32,7 @@ // * // ****************************************************************** #define _CXBXKRNL_INTERNAL -#define _XBOXKRNL_LOCAL_ +#define _XBOXKRNL_DEFEXTRN_ #include diff --git a/Source/Win32/CxbxKrnl/EmuXG.cpp b/Source/Win32/CxbxKrnl/EmuXG.cpp index 9d33d84e6..b938f3d57 100644 --- a/Source/Win32/CxbxKrnl/EmuXG.cpp +++ b/Source/Win32/CxbxKrnl/EmuXG.cpp @@ -32,7 +32,7 @@ // * // ****************************************************************** #define _CXBXKRNL_INTERNAL -#define _XBOXKRNL_LOCAL_ +#define _XBOXKRNL_DEFEXTRN_ #undef FIELD_OFFSET // prevent macro redefinition warnings #include diff --git a/Source/Win32/CxbxKrnl/EmuXOnline.cpp b/Source/Win32/CxbxKrnl/EmuXOnline.cpp index 10515cf05..8534fdfd5 100644 --- a/Source/Win32/CxbxKrnl/EmuXOnline.cpp +++ b/Source/Win32/CxbxKrnl/EmuXOnline.cpp @@ -32,7 +32,7 @@ // * // ****************************************************************** #define _CXBXKRNL_INTERNAL -#define _XBOXKRNL_LOCAL_ +#define _XBOXKRNL_DEFEXTRN_ #include "Emu.h" #include "EmuFS.h" diff --git a/Source/Win32/CxbxKrnl/EmuXapi.cpp b/Source/Win32/CxbxKrnl/EmuXapi.cpp index a22d511e6..c0da3ee82 100644 --- a/Source/Win32/CxbxKrnl/EmuXapi.cpp +++ b/Source/Win32/CxbxKrnl/EmuXapi.cpp @@ -32,7 +32,7 @@ // * // ****************************************************************** #define _CXBXKRNL_INTERNAL -#define _XBOXKRNL_LOCAL_ +#define _XBOXKRNL_DEFEXTRN_ #undef FIELD_OFFSET // prevent macro redefinition warnings #include diff --git a/Source/Win32/CxbxKrnl/HLEDataBase.cpp b/Source/Win32/CxbxKrnl/HLEDataBase.cpp index 72494caf7..70fecd3e1 100644 --- a/Source/Win32/CxbxKrnl/HLEDataBase.cpp +++ b/Source/Win32/CxbxKrnl/HLEDataBase.cpp @@ -32,7 +32,7 @@ // * // ****************************************************************** #define _CXBXKRNL_INTERNAL -#define _XBOXKRNL_LOCAL_ +#define _XBOXKRNL_DEFEXTRN_ #undef FIELD_OFFSET // prevent macro redefinition warnings #include diff --git a/Source/Win32/CxbxKrnl/KernelThunk.cpp b/Source/Win32/CxbxKrnl/KernelThunk.cpp index d8ee92a12..0f76e20af 100644 --- a/Source/Win32/CxbxKrnl/KernelThunk.cpp +++ b/Source/Win32/CxbxKrnl/KernelThunk.cpp @@ -32,7 +32,7 @@ // * // ****************************************************************** #define _CXBXKRNL_INTERNAL -#define _XBOXKRNL_LOCAL_ +#define _XBOXKRNL_DEFEXTRN_ // prevent name collisions namespace xboxkrnl diff --git a/Source/Win32/EmuShared.cpp b/Source/Win32/EmuShared.cpp index 3c2dd7312..d1bc7fa7e 100644 --- a/Source/Win32/EmuShared.cpp +++ b/Source/Win32/EmuShared.cpp @@ -32,7 +32,7 @@ // * // ****************************************************************** #define _CXBXKRNL_INTERNAL -#define _XBOXKRNL_LOCAL_ +#define _XBOXKRNL_DEFEXTRN_ #include "Emu.h" #include "EmuShared.h"