Skip to content
Permalink
Browse files

Core/FifoAnalyzer: Make functions internally linked where applicable

These functions are only used internally within FifoAnalyzer.cpp, so
they can be hidden from external use.
  • Loading branch information...
lioncash committed Jul 15, 2019
1 parent 8d8d103 commit 53779aa73209e521e431e0c8b2b105f97a7c1c5a
Showing with 106 additions and 109 deletions.
  1. +106 −103 Source/Core/Core/FifoPlayer/FifoAnalyzer.cpp
  2. +0 −6 Source/Core/Core/FifoPlayer/FifoAnalyzer.h
@@ -20,30 +20,130 @@

namespace FifoAnalyzer
{
bool s_DrawingObject;
FifoAnalyzer::CPMemory s_CpMem;

namespace
{
u8 ReadFifo8(const u8*& data)
{
u8 value = data[0];
const u8 value = data[0];
data += 1;
return value;
}

u16 ReadFifo16(const u8*& data)
{
u16 value = Common::swap16(data);
const u16 value = Common::swap16(data);
data += 2;
return value;
}

u32 ReadFifo32(const u8*& data)
{
u32 value = Common::swap32(data);
const u32 value = Common::swap32(data);
data += 4;
return value;
}

void CalculateVertexElementSizes(int sizes[], int vatIndex, const CPMemory& cpMem)
{
const TVtxDesc& vtxDesc = cpMem.vtxDesc;
const VAT& vtxAttr = cpMem.vtxAttr[vatIndex];

// Colors
const u64 colDesc[2] = {vtxDesc.Color0, vtxDesc.Color1};
const u32 colComp[2] = {vtxAttr.g0.Color0Comp, vtxAttr.g0.Color1Comp};

const u32 tcElements[8] = {vtxAttr.g0.Tex0CoordElements, vtxAttr.g1.Tex1CoordElements,
vtxAttr.g1.Tex2CoordElements, vtxAttr.g1.Tex3CoordElements,
vtxAttr.g1.Tex4CoordElements, vtxAttr.g2.Tex5CoordElements,
vtxAttr.g2.Tex6CoordElements, vtxAttr.g2.Tex7CoordElements};

const u32 tcFormat[8] = {vtxAttr.g0.Tex0CoordFormat, vtxAttr.g1.Tex1CoordFormat,
vtxAttr.g1.Tex2CoordFormat, vtxAttr.g1.Tex3CoordFormat,
vtxAttr.g1.Tex4CoordFormat, vtxAttr.g2.Tex5CoordFormat,
vtxAttr.g2.Tex6CoordFormat, vtxAttr.g2.Tex7CoordFormat};

// Add position and texture matrix indices
u64 vtxDescHex = cpMem.vtxDesc.Hex;
for (int i = 0; i < 9; ++i)
{
sizes[i] = vtxDescHex & 1;
vtxDescHex >>= 1;
}

// Position
sizes[9] = VertexLoader_Position::GetSize(vtxDesc.Position, vtxAttr.g0.PosFormat,
vtxAttr.g0.PosElements);

// Normals
if (vtxDesc.Normal != NOT_PRESENT)
{
sizes[10] = VertexLoader_Normal::GetSize(vtxDesc.Normal, vtxAttr.g0.NormalFormat,
vtxAttr.g0.NormalElements, vtxAttr.g0.NormalIndex3);
}
else
{
sizes[10] = 0;
}

// Colors
for (int i = 0; i < 2; i++)
{
int size = 0;

switch (colDesc[i])
{
case NOT_PRESENT:
break;
case DIRECT:
switch (colComp[i])
{
case FORMAT_16B_565:
size = 2;
break;
case FORMAT_24B_888:
size = 3;
break;
case FORMAT_32B_888x:
size = 4;
break;
case FORMAT_16B_4444:
size = 2;
break;
case FORMAT_24B_6666:
size = 3;
break;
case FORMAT_32B_8888:
size = 4;
break;
default:
ASSERT(0);
break;
}
break;
case INDEX8:
size = 1;
break;
case INDEX16:
size = 2;
break;
}

sizes[11 + i] = size;
}

// Texture coordinates
vtxDescHex = vtxDesc.Hex >> 17;
for (int i = 0; i < 8; i++)
{
sizes[13 + i] = VertexLoader_TextCoord::GetSize(vtxDescHex & 3, tcFormat[i], tcElements[i]);
vtxDescHex >>= 2;
}
}
} // Anonymous namespace

bool s_DrawingObject;
FifoAnalyzer::CPMemory s_CpMem;

u32 AnalyzeCommand(const u8* data, DecodeMode mode)
{
const u8* dataStart = data;
@@ -188,101 +288,4 @@ void LoadCPReg(u32 subCmd, u32 value, CPMemory& cpMem)
break;
}
}

void CalculateVertexElementSizes(int sizes[], int vatIndex, const CPMemory& cpMem)
{
const TVtxDesc& vtxDesc = cpMem.vtxDesc;
const VAT& vtxAttr = cpMem.vtxAttr[vatIndex];

// Colors
const u64 colDesc[2] = {vtxDesc.Color0, vtxDesc.Color1};
const u32 colComp[2] = {vtxAttr.g0.Color0Comp, vtxAttr.g0.Color1Comp};

const u32 tcElements[8] = {vtxAttr.g0.Tex0CoordElements, vtxAttr.g1.Tex1CoordElements,
vtxAttr.g1.Tex2CoordElements, vtxAttr.g1.Tex3CoordElements,
vtxAttr.g1.Tex4CoordElements, vtxAttr.g2.Tex5CoordElements,
vtxAttr.g2.Tex6CoordElements, vtxAttr.g2.Tex7CoordElements};

const u32 tcFormat[8] = {vtxAttr.g0.Tex0CoordFormat, vtxAttr.g1.Tex1CoordFormat,
vtxAttr.g1.Tex2CoordFormat, vtxAttr.g1.Tex3CoordFormat,
vtxAttr.g1.Tex4CoordFormat, vtxAttr.g2.Tex5CoordFormat,
vtxAttr.g2.Tex6CoordFormat, vtxAttr.g2.Tex7CoordFormat};

// Add position and texture matrix indices
u64 vtxDescHex = cpMem.vtxDesc.Hex;
for (int i = 0; i < 9; ++i)
{
sizes[i] = vtxDescHex & 1;
vtxDescHex >>= 1;
}

// Position
sizes[9] = VertexLoader_Position::GetSize(vtxDesc.Position, vtxAttr.g0.PosFormat,
vtxAttr.g0.PosElements);

// Normals
if (vtxDesc.Normal != NOT_PRESENT)
{
sizes[10] = VertexLoader_Normal::GetSize(vtxDesc.Normal, vtxAttr.g0.NormalFormat,
vtxAttr.g0.NormalElements, vtxAttr.g0.NormalIndex3);
}
else
{
sizes[10] = 0;
}

// Colors
for (int i = 0; i < 2; i++)
{
int size = 0;

switch (colDesc[i])
{
case NOT_PRESENT:
break;
case DIRECT:
switch (colComp[i])
{
case FORMAT_16B_565:
size = 2;
break;
case FORMAT_24B_888:
size = 3;
break;
case FORMAT_32B_888x:
size = 4;
break;
case FORMAT_16B_4444:
size = 2;
break;
case FORMAT_24B_6666:
size = 3;
break;
case FORMAT_32B_8888:
size = 4;
break;
default:
ASSERT(0);
break;
}
break;
case INDEX8:
size = 1;
break;
case INDEX16:
size = 2;
break;
}

sizes[11 + i] = size;
}

// Texture coordinates
vtxDescHex = vtxDesc.Hex >> 17;
for (int i = 0; i < 8; i++)
{
sizes[13 + i] = VertexLoader_TextCoord::GetSize(vtxDescHex & 3, tcFormat[i], tcElements[i]);
vtxDescHex >>= 2;
}
}
} // namespace FifoAnalyzer
@@ -10,10 +10,6 @@

namespace FifoAnalyzer
{
u8 ReadFifo8(const u8*& data);
u16 ReadFifo16(const u8*& data);
u32 ReadFifo32(const u8*& data);

enum DecodeMode
{
DECODE_RECORD,
@@ -32,8 +28,6 @@ struct CPMemory

void LoadCPReg(u32 subCmd, u32 value, CPMemory& cpMem);

void CalculateVertexElementSizes(int sizes[], int vatIndex, const CPMemory& cpMem);

extern bool s_DrawingObject;
extern FifoAnalyzer::CPMemory s_CpMem;
} // namespace FifoAnalyzer

0 comments on commit 53779aa

Please sign in to comment.
You can’t perform that action at this time.