Merge pull request #115 from PatrickvL/master
Battlestart Galactica texture fixes
This commit is contained in:
commit
56b43297c7
|
@ -4689,14 +4689,10 @@ HRESULT WINAPI XTL::EmuIDirect3DResource8_Register
|
||||||
// ARGB texture format
|
// ARGB texture format
|
||||||
if (Format == D3DFMT_P8) //Palette
|
if (Format == D3DFMT_P8) //Palette
|
||||||
{
|
{
|
||||||
/*EmuWarning("D3DFMT_P8 -> D3DFMT_A8R8G8B8");
|
EmuWarning("D3DFMT_P8 -> D3DFMT_A8R8G8B8");
|
||||||
|
|
||||||
CacheFormat = Format; // Save this for later
|
CacheFormat = Format; // Save this for later
|
||||||
Format = D3DFMT_A8R8G8B8; */ // ARGB
|
Format = D3DFMT_A8R8G8B8; // ARGB
|
||||||
|
|
||||||
// Temporarily use the LoveMhz hack
|
|
||||||
EmuWarning("D3DFMT_P8 -> D3DFMT_L8");
|
|
||||||
Format = D3DFMT_L8;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bCubemap)
|
if(bCubemap)
|
||||||
|
@ -4815,7 +4811,15 @@ HRESULT WINAPI XTL::EmuIDirect3DResource8_Register
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (CacheFormat == D3DFMT_P8) //Palette
|
//__asm int 3;
|
||||||
|
// First we need to unswizzle the texture data
|
||||||
|
XTL::EmuXGUnswizzleRect
|
||||||
|
(
|
||||||
|
pSrc + dwMipOffs, dwMipWidth, dwMipHeight, dwDepth, LockedRect.pBits,
|
||||||
|
LockedRect.Pitch, iRect, iPoint, dwBPP
|
||||||
|
);
|
||||||
|
|
||||||
|
if (CacheFormat == D3DFMT_P8) //Palette
|
||||||
{
|
{
|
||||||
EmuWarning("Unsupported texture format D3DFMT_P8,\nexpanding to D3DFMT_A8R8G8B8");
|
EmuWarning("Unsupported texture format D3DFMT_P8,\nexpanding to D3DFMT_A8R8G8B8");
|
||||||
//#if 0
|
//#if 0
|
||||||
|
@ -4824,71 +4828,38 @@ HRESULT WINAPI XTL::EmuIDirect3DResource8_Register
|
||||||
//
|
//
|
||||||
//__asm int 3;
|
//__asm int 3;
|
||||||
|
|
||||||
// Attempt to use correct palette sizes
|
|
||||||
DWORD dwPaletteAllocSize = (dwCurrentPaletteSize == -1) ? 256*4 : dwCurrentPaletteSize;
|
|
||||||
|
|
||||||
BYTE *pPixelData = (BYTE*)LockedRect.pBits;
|
BYTE *pPixelData = (BYTE*)LockedRect.pBits;
|
||||||
DWORD dwDataSize = dwMipWidth*dwMipHeight*4;
|
DWORD dwDataSize = dwMipWidth*dwMipHeight;
|
||||||
DWORD dwPaletteSize = dwPaletteAllocSize; //256*4; // Note: This is not allways true, it can be 256- 128- 64- or 32*4
|
DWORD* pExpandedTexture = (DWORD*)CxbxMalloc(dwDataSize * sizeof(DWORD));
|
||||||
|
DWORD* pTexturePalette = (DWORD*)pCurrentPalette;
|
||||||
BYTE* pTextureCache = (BYTE*)CxbxMalloc(dwDataSize);
|
|
||||||
BYTE* pExpandedTexture = (BYTE*)CxbxMalloc(dwDataSize);
|
|
||||||
BYTE* pTexturePalette = (BYTE*)CxbxMalloc(dwPaletteAllocSize);
|
|
||||||
|
|
||||||
//__asm int 3;
|
|
||||||
// First we need to unswizzle the texture data
|
|
||||||
XTL::EmuXGUnswizzleRect
|
|
||||||
(
|
|
||||||
pSrc + dwMipOffs, dwMipWidth, dwMipHeight, dwDepth, LockedRect.pBits,
|
|
||||||
LockedRect.Pitch, iRect, iPoint, dwBPP
|
|
||||||
);
|
|
||||||
|
|
||||||
//__asm int 3;
|
|
||||||
// Copy the unswizzled data to a temporary buffer
|
|
||||||
memcpy(pTextureCache, pPixelData, dwDataSize);
|
|
||||||
|
|
||||||
//__asm int 3;
|
|
||||||
// Copy the currently selected palette's data to the buffer
|
|
||||||
memcpy(pTexturePalette, pCurrentPalette, dwPaletteSize);
|
|
||||||
|
|
||||||
//__asm int 3;
|
//__asm int 3;
|
||||||
unsigned int w = 0;
|
unsigned int w = 0;
|
||||||
unsigned int c = 0;
|
unsigned int x = 0;
|
||||||
unsigned char p = 0;
|
for (unsigned int y = 0;y < dwDataSize;y++)
|
||||||
for (unsigned int y = 0;y < dwDataSize/4;y++)
|
|
||||||
{
|
{
|
||||||
if(c == dwMipWidth)
|
// Read P8 pixel :
|
||||||
|
unsigned char p = (unsigned char)pPixelData[w++];
|
||||||
|
// Read the corresponding ARGB from the palette and store it in the new texture :
|
||||||
|
pExpandedTexture[y] = pTexturePalette[p];
|
||||||
|
// are we at the end of a line?
|
||||||
|
if(++x == dwMipWidth)
|
||||||
{
|
{
|
||||||
w += dwMipWidth*3;
|
x = 0;
|
||||||
c = 0;
|
// Since P8 contains byte pixels instead of dword ARGB pixels,
|
||||||
|
// the next line resides 3 bytes additional per pixel further :
|
||||||
|
w += dwMipWidth * (sizeof(DWORD) - sizeof(BYTE));
|
||||||
}
|
}
|
||||||
p = (unsigned char)pTextureCache[w];
|
|
||||||
pExpandedTexture[y*4+0] = pTexturePalette[p*4+0];
|
|
||||||
pExpandedTexture[y*4+1] = pTexturePalette[p*4+1];
|
|
||||||
pExpandedTexture[y*4+2] = pTexturePalette[p*4+2];
|
|
||||||
pExpandedTexture[y*4+3] = pTexturePalette[p*4+3];
|
|
||||||
w++;
|
|
||||||
c++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//__asm int 3;
|
//__asm int 3;
|
||||||
// Copy the expanded texture back to the buffer
|
// Copy the expanded texture back to the buffer
|
||||||
memcpy(pPixelData, pExpandedTexture, dwDataSize);
|
memcpy(pPixelData, pExpandedTexture, dwDataSize * sizeof(DWORD));
|
||||||
|
|
||||||
// Flush unused data buffers
|
// Flush unused data buffers
|
||||||
CxbxFree(pTexturePalette);
|
|
||||||
CxbxFree(pExpandedTexture);
|
CxbxFree(pExpandedTexture);
|
||||||
CxbxFree(pTextureCache);
|
|
||||||
//#endif
|
//#endif
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
XTL::EmuXGUnswizzleRect
|
|
||||||
(
|
|
||||||
pSrc + dwMipOffs, dwMipWidth, dwMipHeight, dwDepth, LockedRect.pBits,
|
|
||||||
LockedRect.Pitch, iRect, iPoint, dwBPP
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(bCompressed)
|
else if(bCompressed)
|
||||||
|
@ -5020,7 +4991,7 @@ HRESULT WINAPI XTL::EmuIDirect3DResource8_Register
|
||||||
{
|
{
|
||||||
X_D3DFixup *pFixup = (X_D3DFixup*)pResource;
|
X_D3DFixup *pFixup = (X_D3DFixup*)pResource;
|
||||||
|
|
||||||
CxbxKrnlCleanup("IDirect3DReosurce8::Register -> X_D3DCOMMON_TYPE_FIXUP is not yet supported\n"
|
CxbxKrnlCleanup("IDirect3DResource8::Register -> X_D3DCOMMON_TYPE_FIXUP is not yet supported\n"
|
||||||
"0x%.08X (pFixup->Common) \n"
|
"0x%.08X (pFixup->Common) \n"
|
||||||
"0x%.08X (pFixup->Data) \n"
|
"0x%.08X (pFixup->Data) \n"
|
||||||
"0x%.08X (pFixup->Lock) \n"
|
"0x%.08X (pFixup->Lock) \n"
|
||||||
|
@ -6364,19 +6335,22 @@ VOID WINAPI XTL::EmuIDirect3DDevice8_SetRenderState_BackFillMode
|
||||||
DWORD Value
|
DWORD Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
DbgPrintf("EmuD3D8: EmuIDirect3DDevice8_SetRenderState_BackFillMode\n"
|
DbgPrintf("EmuD3D8: EmuIDirect3DDevice8_SetRenderState_BackFillMode\n"
|
||||||
"(\n"
|
"(\n"
|
||||||
" Value : 0x%.08X\n"
|
" Value : 0x%.08X\n"
|
||||||
");\n",
|
");\n",
|
||||||
Value);
|
Value);
|
||||||
|
|
||||||
EmuWarning("BackFillMode is not supported!");
|
// blueshogun96 12/4/07
|
||||||
|
// I haven't had access to Cxbx sources in a few months, great to be back :)
|
||||||
|
//
|
||||||
|
// Anyway, since standard Direct3D doesn't support the back fill mode
|
||||||
return;
|
// operation, this function will be ignored. Things like this make me
|
||||||
|
// think even more that an OpenGL port wouldn't hurt since OpenGL supports
|
||||||
|
// nearly all of the missing features that Direct3D lacks. The Xbox's version
|
||||||
|
// of Direct3D was specifically created to take advantage of certain NVIDIA
|
||||||
|
// GPU registers and provide more OpenGL-like features IHMO.
|
||||||
|
EmuWarning("BackFillMode is not supported!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
|
@ -9452,38 +9426,6 @@ HRESULT WINAPI XTL::EmuIDirect3DDevice8_GetProjectionViewportMatrix
|
||||||
}
|
}
|
||||||
#pragma warning(default:4244)
|
#pragma warning(default:4244)
|
||||||
|
|
||||||
// ******************************************************************
|
|
||||||
// * func: EmuIDirect3DDevice8_BackFillMode
|
|
||||||
// ******************************************************************
|
|
||||||
HRESULT WINAPI XTL::EmuIDirect3DDevice8_BackFillMode
|
|
||||||
(
|
|
||||||
DWORD Value
|
|
||||||
)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
DbgPrintf("EmuD3D8: EmuIDirect3DDevice8_BackFillMode\n"
|
|
||||||
"(\n"
|
|
||||||
" Value : 0x%.08X\n"
|
|
||||||
");\n",
|
|
||||||
Value);
|
|
||||||
|
|
||||||
|
|
||||||
// blueshogun96 12/4/07
|
|
||||||
// I haven't had access to Cxbx sources in a few months, great to be back :)
|
|
||||||
//
|
|
||||||
// Anyway, since standard Direct3D doesn't support the back fill mode
|
|
||||||
// operation, this function will be ignored. Things like this make me
|
|
||||||
// think even more that an OpenGL port wouldn't hurt since OpenGL supports
|
|
||||||
// nearly all of the missing features that Direct3D lacks. The Xbox's version
|
|
||||||
// of Direct3D was specifically created to take advantage of certain NVIDIA
|
|
||||||
// GPU registers and provide more OpenGL-like features IHMO.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
// * func: EmuD3DDevice_KickOff (D3D::CDevice::KickOff)
|
// * func: EmuD3DDevice_KickOff (D3D::CDevice::KickOff)
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
|
|
|
@ -1706,14 +1706,6 @@ HRESULT WINAPI EmuIDirect3DDevice8_GetProjectionViewportMatrix
|
||||||
D3DXMATRIX *pProjectionViewport
|
D3DXMATRIX *pProjectionViewport
|
||||||
);
|
);
|
||||||
|
|
||||||
// ******************************************************************
|
|
||||||
// * func: EmuIDirect3DDevice8_BackFillMode
|
|
||||||
// ******************************************************************
|
|
||||||
HRESULT WINAPI EmuIDirect3DDevice8_BackFillMode
|
|
||||||
(
|
|
||||||
DWORD Value
|
|
||||||
);
|
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
// * func: EmuD3DDevice_KickOff (D3D::CDevice::KickOff)
|
// * func: EmuD3DDevice_KickOff (D3D::CDevice::KickOff)
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
|
|
|
@ -432,9 +432,9 @@ OOVPA_NO_XREF(IDirect3DDevice8_SetVerticalBlankCallback_1_0_4432, 12)
|
||||||
OOVPA_END;
|
OOVPA_END;
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
// * IDirect3DDevice8_BackFillMode
|
// * IDirect3DDevice8_SetRenderState_BackFillMode
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
OOVPA_NO_XREF(IDirect3DDevice8_BackFillMode_1_0_4531, 9)
|
OOVPA_NO_XREF(IDirect3DDevice8_SetRenderState_BackFillMode_1_0_4531, 9)
|
||||||
|
|
||||||
{ 0x04, 0x56 },
|
{ 0x04, 0x56 },
|
||||||
{ 0x10, 0x8B },
|
{ 0x10, 0x8B },
|
||||||
|
@ -845,7 +845,7 @@ OOVPATable D3D8_1_0_4432[] {
|
||||||
// IDirect3DDevice8_GetDeviceCaps (* unchanged since 3925 *)
|
// IDirect3DDevice8_GetDeviceCaps (* unchanged since 3925 *)
|
||||||
OOVPA_TABLE_PATCH(IDirect3DDevice8_GetDeviceCaps_1_0_3925, XTL::EmuIDirect3DDevice8_GetDeviceCaps),
|
OOVPA_TABLE_PATCH(IDirect3DDevice8_GetDeviceCaps_1_0_3925, XTL::EmuIDirect3DDevice8_GetDeviceCaps),
|
||||||
// IDirect3DDevice8_BackFillMode_4531
|
// IDirect3DDevice8_BackFillMode_4531
|
||||||
OOVPA_TABLE_PATCH(IDirect3DDevice8_BackFillMode_1_0_4531, XTL::EmuIDirect3DDevice8_SetRenderState_BackFillMode),
|
OOVPA_TABLE_PATCH(IDirect3DDevice8_SetRenderState_BackFillMode_1_0_4531, XTL::EmuIDirect3DDevice8_SetRenderState_BackFillMode),
|
||||||
// IDirect3DSurface8::GetDesc (* unchanged since 4361 *)
|
// IDirect3DSurface8::GetDesc (* unchanged since 4361 *)
|
||||||
OOVPA_TABLE_PATCH(IDirect3DSurface8_GetDesc_1_0_4361, XTL::EmuIDirect3DSurface8_GetDesc),
|
OOVPA_TABLE_PATCH(IDirect3DSurface8_GetDesc_1_0_4361, XTL::EmuIDirect3DSurface8_GetDesc),
|
||||||
// Get2DSurfacDesc (* unchanged since 4361 *)
|
// Get2DSurfacDesc (* unchanged since 4361 *)
|
||||||
|
|
|
@ -3441,7 +3441,7 @@ OOVPATable D3D8_1_0_4627[] = {
|
||||||
// IDirect3DDevice8_GetProjectionViewportMatrix
|
// IDirect3DDevice8_GetProjectionViewportMatrix
|
||||||
OOVPA_TABLE_PATCH(IDirect3DDevice8_GetProjectionViewportMatrix_1_0_4627, XTL::EmuIDirect3DDevice8_GetProjectionViewportMatrix),
|
OOVPA_TABLE_PATCH(IDirect3DDevice8_GetProjectionViewportMatrix_1_0_4627, XTL::EmuIDirect3DDevice8_GetProjectionViewportMatrix),
|
||||||
// IDirect3DDevice8_BackFillMode (* unchanged since 4531 *)
|
// IDirect3DDevice8_BackFillMode (* unchanged since 4531 *)
|
||||||
OOVPA_TABLE_PATCH(IDirect3DDevice8_BackFillMode_1_0_4531, XTL::EmuIDirect3DDevice8_BackFillMode),
|
OOVPA_TABLE_PATCH(IDirect3DDevice8_SetRenderState_BackFillMode_1_0_4531, XTL::EmuIDirect3DDevice8_SetRenderState_BackFillMode),
|
||||||
// IDirect3DDevice8_GetDeviceCaps (* unchanged since 3925 *)
|
// IDirect3DDevice8_GetDeviceCaps (* unchanged since 3925 *)
|
||||||
OOVPA_TABLE_PATCH(IDirect3DDevice8_GetDeviceCaps_1_0_3925, XTL::EmuIDirect3DDevice8_GetDeviceCaps),
|
OOVPA_TABLE_PATCH(IDirect3DDevice8_GetDeviceCaps_1_0_3925, XTL::EmuIDirect3DDevice8_GetDeviceCaps),
|
||||||
// D3DDevice_SetRenderState_MultiSampleMask
|
// D3DDevice_SetRenderState_MultiSampleMask
|
||||||
|
|
Loading…
Reference in New Issue