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

@ -16,13 +16,14 @@ public:
virtual void EndFrame(void) = 0;
virtual void UploadTextures(unsigned level, unsigned x, unsigned y, unsigned width, unsigned height) = 0;
virtual void AttachMemory(const uint32_t *cullingRAMLoPtr, const uint32_t *cullingRAMHiPtr, const uint32_t *polyRAMPtr, const uint32_t *vromPtr, const uint16_t *textureRAMPtr) = 0;
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 ~IRender3D()
{
}
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()
{
}
};
#endif // INCLUDED_IRENDER3D_H

View file

@ -1298,12 +1298,16 @@ bool CLegacy3D::Init(unsigned xOffset, unsigned yOffset, unsigned xRes, unsigned
}
void CLegacy3D::SetSunClamp(bool enable)
{
}
CLegacy3D::CLegacy3D(const Util::Config::Node &config)
: m_config(config)
{
{
}
void CLegacy3D::SetSignedShade(bool enable)
{
}
CLegacy3D::CLegacy3D(const Util::Config::Node &config)
: m_config(config)
{
cullingRAMLo = NULL;
cullingRAMHi = NULL;
polyRAM = NULL;

View file

@ -334,13 +334,23 @@ public:
* Sets or unsets the clamped light model
*
* Parameters:
* enable Set clamp mode
*/
void SetSunClamp(bool enable);
/*
* CLegacy3D(void):
* ~CLegacy3D(void):
* enable Set clamp mode
*/
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):
*
* Parameters:
* config Configuration object.

View file

@ -15,9 +15,9 @@
namespace New3D {
CNew3D::CNew3D(const Util::Config::Node &config, std::string gameName)
: m_r3dShader(config),
m_r3dScrollFog(config),
m_gameName(gameName)
: m_r3dShader(config),
m_r3dScrollFog(config),
m_gameName(gameName)
{
m_cullingRAMLo = nullptr;
m_cullingRAMHi = nullptr;
@ -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

@ -149,12 +149,22 @@ public:
* Parameters:
* enable Set clamp mode
*/
void SetSunClamp(bool enable);
/*
* CRender3D(config):
* ~CRender3D(void):
*
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):
*
* Constructor and destructor.
*
* Parameters:
@ -200,13 +210,16 @@ private:
/*
* Data
*/
// Misc
std::string m_gameName;
bool m_sunClamp;
// Stepping
int m_step;
// Misc
std::string m_gameName;
// GPU configuration
bool m_sunClamp;
bool m_shadeIsSigned;
// Stepping
int m_step;
int m_offset; // offset to subtract for words 3 and higher of culling nodes
float m_vertexFactor; // fixed-point conversion factor for vertices

View file

@ -150,13 +150,15 @@ void CReal3D::LoadState(CBlockFile *SaveState)
Rendering
******************************************************************************/
static void UpdateRenderConfig(IRender3D *Render3D, uint64_t internalRenderConfig[])
{
bool noSunClamp = (internalRenderConfig[0] & 0x800000) != 0 && (internalRenderConfig[1] & 0x400000) != 0;
Render3D->SetSunClamp(!noSunClamp);
}
void CReal3D::BeginVBlank(int statusCycles)
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)
{
#ifndef NEW_FRAME_TIMING
// Calculate point at which status bit should change value. Currently the same timing is used for both the status bit in ReadRegister