Add support for PSMCT16S CLUTs.

This commit is contained in:
Jean-Philip Desjardins 2016-11-01 21:09:50 -04:00
parent 43ce1be72f
commit 83c5381854
3 changed files with 71 additions and 41 deletions

View File

@ -222,7 +222,7 @@ GLuint CGSH_OpenGL::PreparePalette(const TEX0& tex0)
convertedClut[i] = color;
}
}
else if(tex0.nCPSM == PSMCT16)
else if(tex0.nCPSM == PSMCT16 || tex0.nCPSM == PSMCT16S)
{
assert(tex0.nCSA < 32);
@ -250,7 +250,7 @@ GLuint CGSH_OpenGL::PreparePalette(const TEX0& tex0)
convertedClut[i] = color;
}
}
else if(tex0.nCPSM == PSMCT16)
else if(tex0.nCPSM == PSMCT16 || tex0.nCPSM == PSMCT16S)
{
for(unsigned int i = 0; i < 256; i++)
{

View File

@ -988,6 +988,63 @@ void CGSHandler::SyncCLUT(const TEX0& tex0)
}
}
template <typename Indexor>
bool CGSHandler::ReadCLUT4_16(const TEX0& tex0)
{
bool changed = false;
assert(tex0.nCSA < 32);
Indexor indexor(m_pRAM, tex0.GetCLUTPtr(), 1);
uint32 clutOffset = tex0.nCSA * 16;
uint16* pDst = m_pCLUT + clutOffset;
for(unsigned int j = 0; j < 2; j++)
{
for(unsigned int i = 0; i < 8; i++)
{
uint16 color = indexor.GetPixel(i, j);
if(*pDst != color)
{
changed = true;
}
(*pDst++) = color;
}
}
return changed;
}
template <typename Indexor>
bool CGSHandler::ReadCLUT8_16(const TEX0& tex0)
{
bool changed = false;
Indexor indexor(m_pRAM, tex0.GetCLUTPtr(), 1);
for(unsigned int j = 0; j < 16; j++)
{
for(unsigned int i = 0; i < 16; i++)
{
uint16 color = indexor.GetPixel(i, j);
uint8 index = i + (j * 16);
index = (index & ~0x18) | ((index & 0x08) << 1) | ((index & 0x10) >> 1);
if(m_pCLUT[index] != color)
{
changed = true;
}
m_pCLUT[index] = color;
}
}
return changed;
}
void CGSHandler::ReadCLUT4(const TEX0& tex0)
{
bool updateNeeded = false;
@ -1054,26 +1111,11 @@ void CGSHandler::ReadCLUT4(const TEX0& tex0)
}
else if(tex0.nCPSM == PSMCT16)
{
assert(tex0.nCSA < 32);
CGsPixelFormats::CPixelIndexorPSMCT16 Indexor(m_pRAM, tex0.GetCLUTPtr(), 1);
uint32 clutOffset = tex0.nCSA * 16;
uint16* pDst = m_pCLUT + clutOffset;
for(unsigned int j = 0; j < 2; j++)
{
for(unsigned int i = 0; i < 8; i++)
{
uint16 color = Indexor.GetPixel(i, j);
if(*pDst != color)
{
changed = true;
}
(*pDst++) = color;
}
}
changed = ReadCLUT4_16<CGsPixelFormats::CPixelIndexorPSMCT16>(tex0);
}
else if(tex0.nCPSM == PSMCT16S)
{
changed = ReadCLUT4_16<CGsPixelFormats::CPixelIndexorPSMCT16S>(tex0);
}
else
{
@ -1182,25 +1224,11 @@ void CGSHandler::ReadCLUT8(const TEX0& tex0)
}
else if(tex0.nCPSM == PSMCT16)
{
CGsPixelFormats::CPixelIndexorPSMCT16 Indexor(m_pRAM, tex0.GetCLUTPtr(), 1);
for(unsigned int j = 0; j < 16; j++)
{
for(unsigned int i = 0; i < 16; i++)
{
uint16 color = Indexor.GetPixel(i, j);
uint8 index = i + (j * 16);
index = (index & ~0x18) | ((index & 0x08) << 1) | ((index & 0x10) >> 1);
if(m_pCLUT[index] != color)
{
changed = true;
}
m_pCLUT[index] = color;
}
}
changed = ReadCLUT8_16<CGsPixelFormats::CPixelIndexorPSMCT16>(tex0);
}
else if(tex0.nCPSM == PSMCT16S)
{
changed = ReadCLUT8_16<CGsPixelFormats::CPixelIndexorPSMCT16S>(tex0);
}
else
{

View File

@ -791,6 +791,8 @@ protected:
template <typename Storage> void TransferReadHandlerGeneric(void*, uint32);
void SyncCLUT(const TEX0&);
template <typename Indexor> bool ReadCLUT4_16(const TEX0&);
template <typename Indexor> bool ReadCLUT8_16(const TEX0&);
void ReadCLUT4(const TEX0&);
void ReadCLUT8(const TEX0&);