re-organization
This commit is contained in:
parent
4a88ae0b27
commit
d2a0ed5fb4
66
CxbxKrnl.dsp
66
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
|
||||
|
|
|
@ -34,21 +34,14 @@
|
|||
#ifndef EMUD3D8_H
|
||||
#define EMUD3D8_H
|
||||
|
||||
#include "EmuD3D8Types.h"
|
||||
|
||||
#include "Xbe.h"
|
||||
|
||||
#undef FIELD_OFFSET // prevent macro redefinition warnings
|
||||
#include <windows.h>
|
||||
|
||||
#define DIRECT3D_VERSION 0x0800
|
||||
#include <d3d8.h>
|
||||
#include <d3dx8tex.h>
|
||||
#include <d3d8types.h>
|
||||
#include "Emu.h"
|
||||
|
||||
#define DIRECTDRAW_VERSION 0x0700
|
||||
#include <ddraw.h>
|
||||
|
||||
#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;
|
||||
|
||||
// ******************************************************************
|
||||
|
|
|
@ -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)
|
|
@ -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
|
|
@ -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 <caustik@caustik.com>
|
||||
// *
|
||||
// * 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
|
|
@ -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
|
|
@ -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 <caustik@caustik.com>
|
||||
// *
|
||||
// * All rights reserved
|
||||
// *
|
||||
// ******************************************************************
|
||||
#ifndef EMUD3D8TYPES_H
|
||||
#define EMUD3D8TYPES_H
|
||||
|
||||
// include direct3d 8x headers
|
||||
#define DIRECT3D_VERSION 0x0800
|
||||
#include <d3d8.h>
|
||||
#include <d3dx8tex.h>
|
||||
#include <d3d8types.h>
|
||||
|
||||
// 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
|
|
@ -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"
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
#define _CXBXKRNL_INTERNAL
|
||||
#define _XBOXKRNL_LOCAL_
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
|
||||
// prevent name collisions
|
||||
namespace xboxkrnl
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
#define _CXBXKRNL_INTERNAL
|
||||
#define _XBOXKRNL_LOCAL_
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
|
||||
// prevent name collisions
|
||||
namespace xboxkrnl
|
||||
|
|
|
@ -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
|
|
@ -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 <xboxkrnl/xboxkrnl.h>
|
||||
};
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
|
||||
#include "Emu.h"
|
||||
#include "EmuFS.h"
|
||||
#include "EmuShared.h"
|
||||
|
||||
// prevent name collisions
|
||||
namespace XTL
|
|
@ -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 <caustik@caustik.com>
|
||||
// *
|
||||
// * 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;i<PrimitiveCount/2;i++)
|
||||
{
|
||||
memcpy(pHack1, pOrig1, uiStride*3); // Vertex 0,1,2 := Vertex 0,1,2
|
||||
memcpy(pHack2, pOrig2, uiStride); // Vertex 3 := Vertex 2
|
||||
memcpy(pHack3, pOrig3, uiStride); // Vertex 4 := Vertex 3
|
||||
memcpy(pHack4, pOrig1, uiStride); // Vertex 5 := Vertex 0
|
||||
|
||||
pHack1 += uiStride*6;
|
||||
pHack2 += uiStride*6;
|
||||
pHack3 += uiStride*6;
|
||||
pHack4 += uiStride*6;
|
||||
|
||||
pOrig1 += uiStride*4;
|
||||
pOrig2 += uiStride*4;
|
||||
pOrig3 += uiStride*4;
|
||||
|
||||
if(dwVertexShader & D3DFVF_XYZRHW)
|
||||
{
|
||||
for(int z=0;z<6;z++)
|
||||
{
|
||||
if(((FLOAT*)&pHackVertexData[dwOffset+i*uiStride*6+z*uiStride])[2] == 0.0f)
|
||||
((FLOAT*)&pHackVertexData[dwOffset+i*uiStride*6+z*uiStride])[2] = 1.0f;
|
||||
if(((FLOAT*)&pHackVertexData[dwOffset+i*uiStride*6+z*uiStride])[3] == 0.0f)
|
||||
((FLOAT*)&pHackVertexData[dwOffset+i*uiStride*6+z*uiStride])[3] = 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(PrimitiveType == 3)
|
||||
{
|
||||
memcpy(&pHackVertexData[dwOffset], &pOrigVertexData[dwOffset], dwOriginalSize);
|
||||
memcpy(&pHackVertexData[dwOffset + dwOriginalSize], &pOrigVertexData[dwOffset], uiStride);
|
||||
}
|
||||
|
||||
if(pVertexStreamZeroData == 0)
|
||||
{
|
||||
pOrigVertexBuffer8->Unlock();
|
||||
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();
|
||||
}
|
|
@ -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 <xboxkrnl/xboxkrnl.h>
|
||||
};
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
|
||||
#include "Emu.h"
|
||||
#include "EmuFS.h"
|
||||
#include "EmuShared.h"
|
||||
|
||||
// prevent name collisions
|
||||
namespace XTL
|
|
@ -32,7 +32,7 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
#define _CXBXKRNL_INTERNAL
|
||||
#define _XBOXKRNL_LOCAL_
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
|
||||
#include "Emu.h"
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
#define _CXBXKRNL_INTERNAL
|
||||
#define _XBOXKRNL_LOCAL_
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
|
||||
// prevent name collisions
|
||||
namespace xboxkrnl
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
#define _CXBXKRNL_INTERNAL
|
||||
#define _XBOXKRNL_LOCAL_
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
|
||||
// prevent name collisions
|
||||
namespace xboxkrnl
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
#define _CXBXKRNL_INTERNAL
|
||||
#define _XBOXKRNL_LOCAL_
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
|
||||
#include "EmuFile.h"
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
#define _CXBXKRNL_INTERNAL
|
||||
#define _XBOXKRNL_LOCAL_
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
|
||||
// prevent name collisions
|
||||
namespace xboxkrnl
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
#define _CXBXKRNL_INTERNAL
|
||||
#define _XBOXKRNL_LOCAL_
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
|
||||
#include "Cxbx.h"
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
#define _CXBXKRNL_INTERNAL
|
||||
#define _XBOXKRNL_LOCAL_
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
#define _CXBXKRNL_INTERNAL
|
||||
#define _XBOXKRNL_LOCAL_
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
|
||||
#undef FIELD_OFFSET // prevent macro redefinition warnings
|
||||
#include <windows.h>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
#define _CXBXKRNL_INTERNAL
|
||||
#define _XBOXKRNL_LOCAL_
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
|
||||
#include "Emu.h"
|
||||
#include "EmuFS.h"
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
#define _CXBXKRNL_INTERNAL
|
||||
#define _XBOXKRNL_LOCAL_
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
|
||||
#undef FIELD_OFFSET // prevent macro redefinition warnings
|
||||
#include <windows.h>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
#define _CXBXKRNL_INTERNAL
|
||||
#define _XBOXKRNL_LOCAL_
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
|
||||
#undef FIELD_OFFSET // prevent macro redefinition warnings
|
||||
#include <windows.h>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
#define _CXBXKRNL_INTERNAL
|
||||
#define _XBOXKRNL_LOCAL_
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
|
||||
// prevent name collisions
|
||||
namespace xboxkrnl
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
#define _CXBXKRNL_INTERNAL
|
||||
#define _XBOXKRNL_LOCAL_
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
|
||||
#include "Emu.h"
|
||||
#include "EmuShared.h"
|
||||
|
|
Loading…
Reference in New Issue