Star wars is the only game to pass unsigned fixed shaded values (per vertex brightness) to the renderer. Originally we thought that the specular flag would turn on unsigned values since it's the only game to set specular with these polys, but this logic turned out to be incorrect. The JTAG interface seems to config the GPU to turn on this functionality. (Harry Tuttle)

This commit is contained in:
Ian Curtis 2017-10-05 19:15:00 +00:00
parent 7c84bc6aeb
commit eb798ed15e
6 changed files with 83 additions and 45 deletions

View file

@ -19,6 +19,7 @@ public:
virtual void SetStepping(int stepping) = 0;
virtual bool Init(unsigned xOffset, unsigned yOffset, unsigned xRes, unsigned yRes, unsigned totalXRes, unsigned totalYRes) = 0;
virtual void SetSunClamp(bool enable) = 0;
virtual void SetSignedShade(bool enable) = 0;
virtual ~IRender3D()
{

View file

@ -1301,6 +1301,10 @@ void CLegacy3D::SetSunClamp(bool enable)
{
}
void CLegacy3D::SetSignedShade(bool enable)
{
}
CLegacy3D::CLegacy3D(const Util::Config::Node &config)
: m_config(config)
{

View file

@ -338,6 +338,16 @@ public:
*/
void SetSunClamp(bool enable);
/*
* SetSignedShade(bool enable);
*
* Sets the sign-ness of fixed shading value
*
* Parameters:
* enable Fixed shading is expressed as signed value
*/
void SetSignedShade(bool enable);
/*
* CLegacy3D(void):
* ~CLegacy3D(void):

View file

@ -25,6 +25,10 @@ CNew3D::CNew3D(const Util::Config::Node &config, std::string gameName)
m_vrom = nullptr;
m_textureRAM = nullptr;
m_sunClamp = true;
m_shadeIsSigned = true;
// Fall-back mechanism for games with patched (not working) JTAG
if (m_gameName == "swtrilgy") m_shadeIsSigned = false;
}
CNew3D::~CNew3D()
@ -1130,7 +1134,7 @@ void CNew3D::CacheModel(Model *m, const UINT32 *data)
float shade;
//==========
if (ph.SpecularEnabled()) {
if (!m_shadeIsSigned) {
shade = (ix & 0xFF) / 255.f; // Star wars is the only game to use unsigned fixed shaded values. It's also the only game to set the specular flag on these polys
}
else {
@ -1599,5 +1603,9 @@ void CNew3D::SetSunClamp(bool enable)
m_sunClamp = enable;
}
} // New3D
void CNew3D::SetSignedShade(bool enable)
{
m_shadeIsSigned = enable;
}
} // New3D

View file

@ -151,6 +151,16 @@ public:
*/
void SetSunClamp(bool enable);
/*
* SetSignedShade(bool enable);
*
* Sets the sign-ness of fixed shading value
*
* Parameters:
* enable Fixed shading is expressed as signed value
*/
void SetSignedShade(bool enable);
/*
* CRender3D(config):
* ~CRender3D(void):
@ -203,7 +213,10 @@ private:
// Misc
std::string m_gameName;
// GPU configuration
bool m_sunClamp;
bool m_shadeIsSigned;
// Stepping
int m_step;

View file

@ -153,7 +153,9 @@ void CReal3D::LoadState(CBlockFile *SaveState)
static void UpdateRenderConfig(IRender3D *Render3D, uint64_t internalRenderConfig[])
{
bool noSunClamp = (internalRenderConfig[0] & 0x800000) != 0 && (internalRenderConfig[1] & 0x400000) != 0;
bool shadeIsSigned = (internalRenderConfig[0] & 0x1) == 0;
Render3D->SetSunClamp(!noSunClamp);
Render3D->SetSignedShade(shadeIsSigned);
}
void CReal3D::BeginVBlank(int statusCycles)