Merge pull request #115 from PatrickvL/master

Battlestart Galactica texture fixes
This commit is contained in:
Luke Usher 2017-01-18 15:48:25 +00:00 committed by GitHub
commit 56b43297c7
4 changed files with 42 additions and 108 deletions

View File

@ -4689,14 +4689,10 @@ HRESULT WINAPI XTL::EmuIDirect3DResource8_Register
// ARGB texture format
if (Format == D3DFMT_P8) //Palette
{
/*EmuWarning("D3DFMT_P8 -> D3DFMT_A8R8G8B8");
EmuWarning("D3DFMT_P8 -> D3DFMT_A8R8G8B8");
CacheFormat = Format; // Save this for later
Format = D3DFMT_A8R8G8B8; */ // ARGB
// Temporarily use the LoveMhz hack
EmuWarning("D3DFMT_P8 -> D3DFMT_L8");
Format = D3DFMT_L8;
Format = D3DFMT_A8R8G8B8; // ARGB
}
if(bCubemap)
@ -4815,7 +4811,15 @@ HRESULT WINAPI XTL::EmuIDirect3DResource8_Register
}
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");
//#if 0
@ -4824,71 +4828,38 @@ HRESULT WINAPI XTL::EmuIDirect3DResource8_Register
//
//__asm int 3;
// Attempt to use correct palette sizes
DWORD dwPaletteAllocSize = (dwCurrentPaletteSize == -1) ? 256*4 : dwCurrentPaletteSize;
BYTE *pPixelData = (BYTE*)LockedRect.pBits;
DWORD dwDataSize = dwMipWidth*dwMipHeight*4;
DWORD dwPaletteSize = dwPaletteAllocSize; //256*4; // Note: This is not allways true, it can be 256- 128- 64- or 32*4
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);
DWORD dwDataSize = dwMipWidth*dwMipHeight;
DWORD* pExpandedTexture = (DWORD*)CxbxMalloc(dwDataSize * sizeof(DWORD));
DWORD* pTexturePalette = (DWORD*)pCurrentPalette;
//__asm int 3;
unsigned int w = 0;
unsigned int c = 0;
unsigned char p = 0;
for (unsigned int y = 0;y < dwDataSize/4;y++)
unsigned int x = 0;
for (unsigned int y = 0;y < dwDataSize;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;
c = 0;
x = 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;
// Copy the expanded texture back to the buffer
memcpy(pPixelData, pExpandedTexture, dwDataSize);
memcpy(pPixelData, pExpandedTexture, dwDataSize * sizeof(DWORD));
// Flush unused data buffers
CxbxFree(pTexturePalette);
CxbxFree(pExpandedTexture);
CxbxFree(pTextureCache);
//#endif
}
else
{
XTL::EmuXGUnswizzleRect
(
pSrc + dwMipOffs, dwMipWidth, dwMipHeight, dwDepth, LockedRect.pBits,
LockedRect.Pitch, iRect, iPoint, dwBPP
);
}
}
}
else if(bCompressed)
@ -5020,7 +4991,7 @@ HRESULT WINAPI XTL::EmuIDirect3DResource8_Register
{
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->Data) \n"
"0x%.08X (pFixup->Lock) \n"
@ -6364,19 +6335,22 @@ VOID WINAPI XTL::EmuIDirect3DDevice8_SetRenderState_BackFillMode
DWORD Value
)
{
DbgPrintf("EmuD3D8: EmuIDirect3DDevice8_SetRenderState_BackFillMode\n"
"(\n"
" Value : 0x%.08X\n"
");\n",
Value);
EmuWarning("BackFillMode is not supported!");
return;
// 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.
EmuWarning("BackFillMode is not supported!");
}
// ******************************************************************
@ -9452,38 +9426,6 @@ HRESULT WINAPI XTL::EmuIDirect3DDevice8_GetProjectionViewportMatrix
}
#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)
// ******************************************************************

View File

@ -1706,14 +1706,6 @@ HRESULT WINAPI EmuIDirect3DDevice8_GetProjectionViewportMatrix
D3DXMATRIX *pProjectionViewport
);
// ******************************************************************
// * func: EmuIDirect3DDevice8_BackFillMode
// ******************************************************************
HRESULT WINAPI EmuIDirect3DDevice8_BackFillMode
(
DWORD Value
);
// ******************************************************************
// * func: EmuD3DDevice_KickOff (D3D::CDevice::KickOff)
// ******************************************************************

View File

@ -432,9 +432,9 @@ OOVPA_NO_XREF(IDirect3DDevice8_SetVerticalBlankCallback_1_0_4432, 12)
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 },
{ 0x10, 0x8B },
@ -845,7 +845,7 @@ OOVPATable D3D8_1_0_4432[] {
// IDirect3DDevice8_GetDeviceCaps (* unchanged since 3925 *)
OOVPA_TABLE_PATCH(IDirect3DDevice8_GetDeviceCaps_1_0_3925, XTL::EmuIDirect3DDevice8_GetDeviceCaps),
// 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 *)
OOVPA_TABLE_PATCH(IDirect3DSurface8_GetDesc_1_0_4361, XTL::EmuIDirect3DSurface8_GetDesc),
// Get2DSurfacDesc (* unchanged since 4361 *)

View File

@ -3441,7 +3441,7 @@ OOVPATable D3D8_1_0_4627[] = {
// IDirect3DDevice8_GetProjectionViewportMatrix
OOVPA_TABLE_PATCH(IDirect3DDevice8_GetProjectionViewportMatrix_1_0_4627, XTL::EmuIDirect3DDevice8_GetProjectionViewportMatrix),
// 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 *)
OOVPA_TABLE_PATCH(IDirect3DDevice8_GetDeviceCaps_1_0_3925, XTL::EmuIDirect3DDevice8_GetDeviceCaps),
// D3DDevice_SetRenderState_MultiSampleMask