diff --git a/Cxbx.opt b/Cxbx.opt index e5f0aa37b..5f8138841 100644 Binary files a/Cxbx.opt and b/Cxbx.opt differ diff --git a/Doc/RemovedCode.txt b/Doc/RemovedCode.txt index d41e1c7e9..2a2e1ea33 100644 --- a/Doc/RemovedCode.txt +++ b/Doc/RemovedCode.txt @@ -1,3 +1,50 @@ +>> nice code for dumping textures inside of push buffer stuff + + /* + IDirect3DBaseTexture8 *pTexture = 0; + + g_pD3DDevice8->GetTexture(0, &pTexture); + + if(pTexture != NULL) + { + static int dwDumpTexture = 0; + + char szBuffer[256]; + + printf("Texture Time...\n"); + + switch(pTexture->GetType()) + { + case D3DRTYPE_TEXTURE: + { + printf("_TEXTURE\n"); + sprintf(szBuffer, "C:\\Aaron\\Textures\\PushBufferTex - %.03d (0x%.08X).bmp", dwDumpTexture++, pTexture); + + ((IDirect3DTexture8*)pTexture)->UnlockRect(0); + + D3DXSaveTextureToFile(szBuffer, D3DXIFF_BMP, pTexture, NULL); + } + break; + + case D3DRTYPE_CUBETEXTURE: + { + printf("_CUBETEXTURE\n"); + for(int face=0;face<6;face++) + { + sprintf(szBuffer, "C:\\Aaron\\Textures\\PushBufferTexCube%d - %.03d (0x%.08X).bmp", face, dwDumpTexture++, pTexture); + + ((IDirect3DCubeTexture8*)pTexture)->UnlockRect((D3DCUBEMAP_FACES)face, 0); + + D3DXSaveTextureToFile(szBuffer, D3DXIFF_BMP, pTexture, NULL); + } + } + break; + } + } + //*/ + +<< + >> /* TODO: Use new handle wrapping code diff --git a/Include/Cxbx.h b/Include/Cxbx.h index cf5c0b3f2..45e46f2cb 100644 --- a/Include/Cxbx.h +++ b/Include/Cxbx.h @@ -68,15 +68,15 @@ typedef signed long sint32; // define this to trace warnings #define _DEBUG_WARNINGS -// define this to dump textures @ SetTexture +// define these to dump textures //#define _DEBUG_DUMP_TEXTURE_SETTEXTURE "C:\\Aaron\\Textures\\" //#define _DEBUG_DUMP_TEXTURE_REGISTER "C:\\Aaron\\Textures\\" // version information #ifndef _DEBUG_TRACE -#define _CXBX_VERSION "0.8.0-Pre2" +#define _CXBX_VERSION "0.8.0-Pre3" #else -#define _CXBX_VERSION "0.8.0-Pre2-Trace" +#define _CXBX_VERSION "0.8.0-Pre3-Trace" #endif // round dwValue to the nearest multiple of dwMult diff --git a/Source/Win32/CxbxKrnl/EmuD3D8/PushBuffer.cpp b/Source/Win32/CxbxKrnl/EmuD3D8/PushBuffer.cpp index a2263392e..8329a1462 100644 --- a/Source/Win32/CxbxKrnl/EmuD3D8/PushBuffer.cpp +++ b/Source/Win32/CxbxKrnl/EmuD3D8/PushBuffer.cpp @@ -162,8 +162,6 @@ extern void XTL::EmuExecutePushBufferRaw pVertexData = ++pdwPushData; - // TODO: debug print out of vertex data - pdwPushData += dwCount; // retrieve vertex shader @@ -180,7 +178,20 @@ extern void XTL::EmuExecutePushBufferRaw dwVertexShader = -1; } + // // calculate stride + // + + dwStride = 0; + + if(!VshHandleIsVertexShader(dwVertexShader)) + { + if(dwVertexShader & D3DFVF_XYZRHW) { dwStride += sizeof(FLOAT)*4; } + if(dwVertexShader & D3DFVF_DIFFUSE) { dwStride += sizeof(DWORD); } + if(dwVertexShader & D3DFVF_SPECULAR) { dwStride += sizeof(DWORD); } + + dwStride += ((dwVertexShader & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT)*sizeof(FLOAT)*2; + } /* // create cached vertex buffer only once, with maxed out size @@ -208,10 +219,44 @@ extern void XTL::EmuExecutePushBufferRaw } */ + #ifdef _DEBUG_TRACK_PB + if(bShowPB) + { + printf("NVPB_InlineVertexArray(...)\n"); + printf(" dwCount : %d\n", dwCount); + printf(" dwVertexShader : 0x%08X\n", dwVertexShader); + } + #endif + // render vertices if(dwVertexShader != -1) { - g_pD3DDevice8->DrawPrimitiveUP(PCPrimitiveType, dwCount / dwStride, pVertexData, dwStride); + UINT VertexCount = (dwCount*sizeof(DWORD)) / dwStride; + UINT PrimitiveCount = EmuD3DVertex2PrimitiveCount(XBPrimitiveType, VertexCount); + + VertexPatchDesc VPDesc; + + VPDesc.dwVertexCount = VertexCount; + VPDesc.PrimitiveType = XBPrimitiveType; + VPDesc.dwPrimitiveCount = PrimitiveCount; + VPDesc.dwOffset = 0; + VPDesc.pVertexStreamZeroData = pVertexData; + VPDesc.uiVertexStreamZeroStride = dwStride; + VPDesc.hVertexShader = dwVertexShader; + + VertexPatcher VertPatch; + + bool bPatched = VertPatch.Apply(&VPDesc); + + g_pD3DDevice8->DrawPrimitiveUP + ( + PCPrimitiveType, + VPDesc.dwPrimitiveCount, + VPDesc.pVertexStreamZeroData, + VPDesc.uiVertexStreamZeroStride + ); + + VertPatch.Restore(); } pdwPushData--; diff --git a/Source/Win32/CxbxKrnl/HLEDataBase/Xapi.1.0.4627.inl b/Source/Win32/CxbxKrnl/HLEDataBase/Xapi.1.0.4627.inl index 82b926ea3..d6c6d8a8c 100644 --- a/Source/Win32/CxbxKrnl/HLEDataBase/Xapi.1.0.4627.inl +++ b/Source/Win32/CxbxKrnl/HLEDataBase/Xapi.1.0.4627.inl @@ -321,36 +321,6 @@ SOOVPA<12> XInputGetState_1_0_4928 = -1, // XRef Not Saved 0, // XRef Not Used - { - { 0x0B, 0x8B }, // (Offset,Value)-Pair #1 - { 0x0C, 0x1D }, // (Offset,Value)-Pair #2 - { 0x0D, 0xAC }, // (Offset,Value)-Pair #3 - - { 0x25, 0xF6 }, // (Offset,Value)-Pair #4 - { 0x26, 0x46 }, // (Offset,Value)-Pair #5 - { 0x27, 0x04 }, // (Offset,Value)-Pair #6 - { 0x28, 0x02 }, // (Offset,Value)-Pair #7 - - { 0x39, 0xF3 }, // (Offset,Value)-Pair #8 - { 0x3A, 0xAB }, // (Offset,Value)-Pair #9 - - { 0x90, 0xBF }, // (Offset,Value)-Pair #10 - { 0x91, 0xE8 }, // (Offset,Value)-Pair #11 - { 0x92, 0x7B }, // (Offset,Value)-Pair #12 - } -}; - -// ****************************************************************** -// * XInputSetState -// ****************************************************************** -SOOVPA<12> XInputSetState_1_0_4928 = -{ - 0, // Large == 0 - 12, // Count == 12 - - -1, // XRef Not Saved - 0, // XRef Not Used - { { 0x0E, 0x8B }, // (Offset,Value)-Pair #1 { 0x0F, 0x8A }, // (Offset,Value)-Pair #2 @@ -371,6 +341,36 @@ SOOVPA<12> XInputSetState_1_0_4928 = } }; +// ****************************************************************** +// * XInputGetCapabilities +// ****************************************************************** +SOOVPA<12> XInputGetCapabilities_1_0_4928 = +{ + 0, // Large == 0 + 12, // Count == 12 + + -1, // XRef Not Saved + 0, // XRef Not Used + + { + { 0x0B, 0x8B }, // (Offset,Value)-Pair #1 + { 0x0C, 0x1D }, // (Offset,Value)-Pair #2 + { 0x0D, 0xAC }, // (Offset,Value)-Pair #3 + + { 0x25, 0xF6 }, // (Offset,Value)-Pair #4 + { 0x26, 0x46 }, // (Offset,Value)-Pair #5 + { 0x27, 0x04 }, // (Offset,Value)-Pair #6 + { 0x28, 0x02 }, // (Offset,Value)-Pair #7 + + { 0x39, 0xF3 }, // (Offset,Value)-Pair #8 + { 0x3A, 0xAB }, // (Offset,Value)-Pair #9 + + { 0x90, 0xBF }, // (Offset,Value)-Pair #10 + { 0x91, 0xE8 }, // (Offset,Value)-Pair #11 + { 0x92, 0x7B }, // (Offset,Value)-Pair #12 + } +}; + // ****************************************************************** // * XAPI_1_0_4627 // ****************************************************************** @@ -614,14 +614,14 @@ OOVPATable XAPI_1_0_4627[] = "EmuXInputGetState" #endif }, - // XInputSetState + // XInputGetCapabilities { - (OOVPA*)&XInputSetState_1_0_4928, + (OOVPA*)&XInputGetCapabilities_1_0_4928, - XTL::EmuXInputSetState, + XTL::EmuXInputGetCapabilities, #ifdef _DEBUG_TRACE - "EmuXInputSetState" + "EmuXInputGetCapabilities" #endif }, // XInputSetState (* unchanged since 1.0.4361 *)