Skip to content

Commit

Permalink
Prevent texture tile/scale setting when texture is disabled.
Browse files Browse the repository at this point in the history
Thanks to Salvy.
  • Loading branch information
Rinnegatamante committed Jul 30, 2020
1 parent 0ae81f5 commit 149c63f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 27 deletions.
20 changes: 2 additions & 18 deletions Source/HLEGraphics/BaseRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,7 @@ class BaseRenderer

// Various rendering states
// Don't think we need to updateshademodel, it breaks tiger's honey hunt
#ifdef DAEDALUS_PSP
inline void SetTnLMode(u32 mode) { mTnL.Flags.Modes = mode; /*UpdateFogEnable(); UpdateShadeModel();*/ }
#else
inline void SetTnLMode(u32 mode) { mTnL.Flags.Modes = mode; UpdateFogEnable(); /*UpdateShadeModel();*/ }
#endif
inline void SetTextureEnable(bool enable) { mTnL.Flags.Texture = enable; }
inline void SetTextureTile(u32 tile) { mTextureTile = tile; }
inline u32 GetTextureTile() const { return mTextureTile; }
Expand All @@ -243,20 +239,11 @@ class BaseRenderer
#endif
// Fog stuff
inline void SetFogMultOffs(f32 Mult, f32 Offs) { mTnL.FogMult=Mult/255.0f; mTnL.FogOffs=Offs/255.0f;}
#ifdef DAEDALUS_PSP
inline void SetFogMinMax(f32 fog_near, f32 fog_far) { sceGuFog(fog_near, fog_far, mFogColour.GetColour()); }
inline void SetFogColour( c32 colour ) { mFogColour = colour; }
#elif defined(DAEDALUS_VITA)
inline void SetFogMinMax(f32 fog_near, f32 fog_far) { glFogf(GL_FOG_START, fog_near / 1000.0f); glFogf(GL_FOG_END, fog_far / 1000.0f); }
inline void SetFogColour( c32 colour ) { float fog_clr[4] = {colour.GetRf(), colour.GetGf(), colour.GetBf(), colour.GetAf()}; glFogfv(GL_FOG_COLOR, &fog_clr[0]); }
#endif

// PrimDepth will replace the z value if depth_source=1 (z range 32767-0 while PSP depthbuffer range 0-65535)//Corn
#ifdef DAEDALUS_PSP
inline void SetPrimitiveDepth( u32 z ) { mPrimDepth = (f32)( ( ( 32767 - z ) << 1) + 1 ); }
#else
inline void SetPrimitiveDepth( u32 z ) { mPrimDepth = (f32)((int)z - 0x4000) / 16384.0f;}
#endif
inline void SetPrimitiveLODFraction( f32 f ) { mPrimLODFraction = f; }
inline void SetPrimitiveColour( c32 colour ) { mPrimitiveColour = colour; }
inline void SetEnvColour( c32 colour ) { mEnvColour = colour; }
Expand All @@ -274,7 +261,7 @@ class BaseRenderer
inline void SetCoordMod( u32 idx, f32 mod ) { mTnL.CoordMod[idx] = mod; }
inline void SetMux( u64 mux ) { mMux = mux; }

inline void SetTextureScale(float fScaleX, float fScaleY) { mTnL.TextureScaleX = fScaleX; mTnL.TextureScaleY = fScaleY; }
inline void SetTextureScale(float fScaleX, float fScaleY) { mTnL.TextureScaleX = fScaleX == 0 ? 1/32.0f : fScaleX; mTnL.TextureScaleY = fScaleY == 0 ? 1/32.0f : fScaleY; }
inline void SetTextureScaleX(u32 ScaleX) { mTextureScaleX = ScaleX; }
inline void SetTextureScaleY(u32 ScaleY) { mTextureScaleY = ScaleY; }
inline void SetTextureScaleDAM(u32 scale) { mDAMTexScale = scale; }
Expand Down Expand Up @@ -359,10 +346,7 @@ class BaseRenderer
v2 mVpTrans;

protected:
#if defined(DAEDALUS_PSP)
inline void UpdateFogEnable() { if(gFogEnabled) mTnL.Flags.Fog ? sceGuEnable(GU_FOG) : sceGuDisable(GU_FOG); }
inline void UpdateShadeModel() { sceGuShadeModel( mTnL.Flags.Shade ? GU_SMOOTH : GU_FLAT ); }
#elif defined(DAEDALUS_VITA)
#if defined(DAEDALUS_VITA)
inline void UpdateFogEnable() { mTnL.Flags.Fog ? glEnable(GL_FOG) : glDisable(GL_FOG); }
inline void UpdateShadeModel() {}
#else
Expand Down
2 changes: 1 addition & 1 deletion Source/HLEGraphics/uCodes/Ucode_Conker.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ void DLParser_MoveWord_Conker( MicroCodeCommand command )
#ifdef DAEDALUS_DEBUG_DISPLAYLIST
DL_PF( " G_MW_SEGMENT Segment[%d] = 0x%08x", segment, command.inst.cmd1 );
#endif
gSegments[segment] = command.inst.cmd1;
gSegments[segment] = command.inst.cmd1 & 0x00FFFFFF;
}
break;

Expand Down
2 changes: 1 addition & 1 deletion Source/HLEGraphics/uCodes/Ucode_DKR.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ void DLParser_GBI1_Texture_DKR( MicroCodeCommand command )
u32 tile = command.texture.tile;

// Force enable texture in DKR Ucode, fixes static texture bug etc
gRenderer->SetTextureTile(tile);
gRenderer->SetTextureEnable(true);
gRenderer->SetTextureTile(tile);

f32 scale_s = f32(command.texture.scaleS) / (65535.0f * 32.0f);
f32 scale_t = f32(command.texture.scaleT) / (65535.0f * 32.0f);
Expand Down
14 changes: 9 additions & 5 deletions Source/HLEGraphics/uCodes/Ucode_GBI1.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void DLParser_GBI1_MoveWord( MicroCodeCommand command )
case G_MW_SEGMENT:
{
u32 segment = (offset >> 2) & 0xF;
gSegments[segment] = value;
gSegments[segment] = value & 0x00FFFFFF;
}
break;

Expand Down Expand Up @@ -347,11 +347,15 @@ void DLParser_GBI1_SetOtherModeH( MicroCodeCommand command )
//*****************************************************************************
void DLParser_GBI1_Texture( MicroCodeCommand command )
{
bool enabled = command.texture.enable_gbi0;
gRenderer->SetTextureEnable(enabled);

if (!enabled) return;

gRenderer->SetTextureTile( command.texture.tile);
gRenderer->SetTextureEnable( command.texture.enable_gbi0);

f32 scale_s = f32(command.texture.scaleS) / (65535.0f * 32.0f);
f32 scale_t = f32(command.texture.scaleT) / (65535.0f * 32.0f);

f32 scale_s = f32(command.texture.scaleS) / (65536.0f * 32.0f);
f32 scale_t = f32(command.texture.scaleT) / (65536.0f * 32.0f);

gRenderer->SetTextureScale( scale_s, scale_t );

Expand Down
8 changes: 6 additions & 2 deletions Source/HLEGraphics/uCodes/Ucode_GBI2.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void DLParser_GBI2_MoveWord_AM( MicroCodeCommand command )
{
u32 segment = offset >> 2;
u32 address = value;
gSegments[segment] = address;
gSegments[segment] = address & 0x00FFFFFF;
}
break;
case G_MW_FOG:
Expand Down Expand Up @@ -425,8 +425,12 @@ void DLParser_GBI2_SetOtherModeH( MicroCodeCommand command )
//*****************************************************************************
void DLParser_GBI2_Texture( MicroCodeCommand command )
{
bool enabled = command.texture.enable_gbi2;
gRenderer->SetTextureEnable(enabled);

if (!enabled) return;

gRenderer->SetTextureTile( command.texture.tile );
gRenderer->SetTextureEnable( command.texture.enable_gbi2 );

f32 scale_s = f32(command.texture.scaleS) / (65535.0f * 32.0f);
f32 scale_t = f32(command.texture.scaleT) / (65535.0f * 32.0f);
Expand Down

0 comments on commit 149c63f

Please sign in to comment.