Skip to content

Commit

Permalink
Formatting cleanup for VideoCommon.
Browse files Browse the repository at this point in the history
Block braces on new lines.

Also killed off trailing whitespace and dangling elses.

Spaced some things out to make them more readable (only in places where it looked like a bit of a clusterfuck).
  • Loading branch information
lioncash committed Apr 24, 2013
1 parent c118c71 commit 8da425b
Show file tree
Hide file tree
Showing 35 changed files with 560 additions and 259 deletions.
6 changes: 4 additions & 2 deletions Source/Core/VideoCommon/Src/AVIDump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ bool AVIDump::CreateFile()
return false;
}

if (!m_fileCount) {
if (!SetCompressionOptions()) {
if (!m_fileCount)
{
if (!SetCompressionOptions())
{
NOTICE_LOG(VIDEO, "SetCompressionOptions failed");
Stop();
return false;
Expand Down
93 changes: 48 additions & 45 deletions Source/Core/VideoCommon/Src/BPMemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,17 @@
#define BPMEM_FOGPARAM3 0xF1
#define BPMEM_FOGCOLOR 0xF2
#define BPMEM_ALPHACOMPARE 0xF3
#define BPMEM_BIAS 0xF4
#define BPMEM_ZTEX2 0xF5
#define BPMEM_BIAS 0xF4
#define BPMEM_ZTEX2 0xF5
#define BPMEM_TEV_KSEL 0xF6 // 0xF6 + 8
#define BPMEM_BP_MASK 0xFE


// Tev/combiner things

#define TEVSCALE_1 0
#define TEVSCALE_2 1
#define TEVSCALE_4 2
#define TEVSCALE_1 0
#define TEVSCALE_2 1
#define TEVSCALE_4 2
#define TEVDIVIDE_2 3

#define TEVCMP_R8 0
Expand Down Expand Up @@ -136,22 +136,22 @@
#define TEVCOLORARG_ZERO 15

#define TEVALPHAARG_APREV 0
#define TEVALPHAARG_A0 1
#define TEVALPHAARG_A1 2
#define TEVALPHAARG_A2 3
#define TEVALPHAARG_TEXA 4
#define TEVALPHAARG_RASA 5
#define TEVALPHAARG_A0 1
#define TEVALPHAARG_A1 2
#define TEVALPHAARG_A2 3
#define TEVALPHAARG_TEXA 4
#define TEVALPHAARG_RASA 5
#define TEVALPHAARG_KONST 6
#define TEVALPHAARG_ZERO 7
#define TEVALPHAARG_ZERO 7

#define ALPHACMP_NEVER 0
#define ALPHACMP_LESS 1
#define ALPHACMP_EQUAL 2
#define ALPHACMP_LEQUAL 3
#define ALPHACMP_NEVER 0
#define ALPHACMP_LESS 1
#define ALPHACMP_EQUAL 2
#define ALPHACMP_LEQUAL 3
#define ALPHACMP_GREATER 4
#define ALPHACMP_NEQUAL 5
#define ALPHACMP_GEQUAL 6
#define ALPHACMP_ALWAYS 7
#define ALPHACMP_NEQUAL 5
#define ALPHACMP_GEQUAL 6
#define ALPHACMP_ALWAYS 7

enum Compare
{
Expand Down Expand Up @@ -313,26 +313,26 @@ struct TevStageCombiner
#define ITF_3 3

#define ITB_NONE 0
#define ITB_S 1
#define ITB_T 2
#define ITB_ST 3
#define ITB_U 4
#define ITB_SU 5
#define ITB_TU 6
#define ITB_STU 7
#define ITB_S 1
#define ITB_T 2
#define ITB_ST 3
#define ITB_U 4
#define ITB_SU 5
#define ITB_TU 6
#define ITB_STU 7

#define ITBA_OFF 0
#define ITBA_S 1
#define ITBA_T 2
#define ITBA_U 3
#define ITBA_S 1
#define ITBA_T 2
#define ITBA_U 3

#define ITW_OFF 0
#define ITW_256 1
#define ITW_128 2
#define ITW_64 3
#define ITW_32 4
#define ITW_16 5
#define ITW_0 6
#define ITW_64 3
#define ITW_32 4
#define ITW_16 5
#define ITW_0 6

// several discoveries:
// GXSetTevIndBumpST(tevstage, indstage, matrixind)
Expand Down Expand Up @@ -366,7 +366,7 @@ struct TevStageCombiner
u32 unused : 11;
};

bool IsActive() { return (hex&0x17fe00)!=0; }
bool IsActive() { return (hex & 0x17fe00) != 0; }
};

union TwoTevStageOrders
Expand Down Expand Up @@ -464,7 +464,7 @@ union TexImage0
{
struct
{
u32 width : 10; //actually w-1
u32 width : 10; //actually w-1
u32 height : 10; //actually h-1
u32 format : 4;
};
Expand Down Expand Up @@ -542,14 +542,14 @@ union ZTex2

struct FourTexUnits
{
TexMode0 texMode0[4];
TexMode1 texMode1[4];
TexImage0 texImage0[4];
TexImage1 texImage1[4];
TexImage2 texImage2[4];
TexImage3 texImage3[4];
TexTLUT texTlut[4];
u32 unknown[4];
TexMode0 texMode0[4];
TexMode1 texMode1[4];
TexImage0 texImage0[4];
TexImage1 texImage1[4];
TexImage2 texImage2[4];
TexImage3 texImage3[4];
TexTLUT texTlut[4];
u32 unknown[4];
};


Expand Down Expand Up @@ -646,7 +646,8 @@ union FogParam0
u32 sign : 1;
};

float GetA() {
float GetA()
{
union { u32 i; float f; } dummy;
dummy.i = ((u32)sign << 31) | ((u32)exponent << 23) | ((u32)mantissa << 12); // scale mantissa from 11 to 23 bits
return dummy.f;
Expand All @@ -667,7 +668,8 @@ union FogParam3
};

// amount to subtract from eyespacez after range adjustment
float GetC() {
float GetC()
{
union { u32 i; float f; } dummy;
dummy.i = ((u32)c_sign << 31) | ((u32)c_exp << 23) | ((u32)c_mant << 12); // scale mantissa from 11 to 23 bits
return dummy.f;
Expand Down Expand Up @@ -906,7 +908,8 @@ union UPE_Copy
union BPU_PreloadTileInfo
{
u32 hex;
struct {
struct
{
u32 count : 15;
u32 type : 2;
};
Expand Down
56 changes: 33 additions & 23 deletions Source/Core/VideoCommon/Src/BPStructs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ void BPWritten(const BPCmd& bp)
if (!mapTexFound)
{
if (bp.address != BPMEM_TEV_COLOR_ENV && bp.address != BPMEM_TEV_ALPHA_ENV)
{
numWrites = 0;
}
else if (++numWrites >= 100) // seem that if 100 consecutive BP writes are called to either of these addresses in ZTP,
{ // then it is safe to assume the map texture address is currently loaded into the BP memory
mapTexAddress = bpmem.tex[0].texImage3[0].hex << 5;
Expand Down Expand Up @@ -193,15 +195,19 @@ void BPWritten(const BPCmd& bp)
PRIM_LOG("blendmode: en=%d, open=%d, colupd=%d, alphaupd=%d, dst=%d, src=%d, sub=%d, mode=%d",
bpmem.blendmode.blendenable, bpmem.blendmode.logicopenable, bpmem.blendmode.colorupdate, bpmem.blendmode.alphaupdate,
bpmem.blendmode.dstfactor, bpmem.blendmode.srcfactor, bpmem.blendmode.subtract, bpmem.blendmode.logicmode);

// Set LogicOp Blending Mode
if (bp.changes & 2)
SetLogicOpMode();

// Set Dithering Mode
if (bp.changes & 4)
SetDitherMode();

// Set Blending Mode
if (bp.changes & 0xFF1)
SetBlendMode();

// Set Color Mask
if (bp.changes & 0x18)
SetColorMask();
Expand Down Expand Up @@ -413,40 +419,44 @@ void BPWritten(const BPCmd& bp)
case BPMEM_CLEARBBOX1:
case BPMEM_CLEARBBOX2:
{
if(g_ActiveConfig.bUseBBox)
{
// Don't compute bounding box if this frame is being skipped!
// Wrong but valid values are better than bogus values...
if(g_bSkipCurrentFrame)
break;
if(g_ActiveConfig.bUseBBox)
{
// Don't compute bounding box if this frame is being skipped!
// Wrong but valid values are better than bogus values...
if(g_bSkipCurrentFrame)
break;

if (bp.address == BPMEM_CLEARBBOX1) {
int right = bp.newvalue >> 10;
int left = bp.newvalue & 0x3ff;
if (bp.address == BPMEM_CLEARBBOX1)
{
int right = bp.newvalue >> 10;
int left = bp.newvalue & 0x3ff;

// We should only set these if bbox is calculated properly.
PixelEngine::bbox[0] = left;
PixelEngine::bbox[1] = right;
PixelEngine::bbox_active = true;
} else {
int bottom = bp.newvalue >> 10;
int top = bp.newvalue & 0x3ff;

// We should only set these if bbox is calculated properly.
PixelEngine::bbox[2] = top;
PixelEngine::bbox[3] = bottom;
PixelEngine::bbox_active = true;
// We should only set these if bbox is calculated properly.
PixelEngine::bbox[0] = left;
PixelEngine::bbox[1] = right;
PixelEngine::bbox_active = true;
}
else
{
int bottom = bp.newvalue >> 10;
int top = bp.newvalue & 0x3ff;

// We should only set these if bbox is calculated properly.
PixelEngine::bbox[2] = top;
PixelEngine::bbox[3] = bottom;
PixelEngine::bbox_active = true;
}
}
}
}
break;
case BPMEM_TEXINVALIDATE:
// TODO: Needs some restructuring in TextureCacheBase.
break;

case BPMEM_ZCOMPARE: // Set the Z-Compare and EFB pixel format
OnPixelFormatChange();
if(bp.changes & 7) {
if(bp.changes & 7)
{
SetBlendMode(); // dual source could be activated by changing to PIXELFMT_RGBA6_Z24
g_renderer->SetColorMask(); // alpha writing needs to be disabled if the new pixel format doesn't have an alpha channel
}
Expand Down
4 changes: 3 additions & 1 deletion Source/Core/VideoCommon/Src/CPMemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ union TVtxDesc
u32 Tex7Coord : 2;
u32 :31;
};
struct {

struct
{
u32 Hex0, Hex1;
};
};
Expand Down
Loading

0 comments on commit 8da425b

Please sign in to comment.