Use CP constants in FifoAnalyzer

This commit is contained in:
Pokechu22 2021-03-10 12:48:52 -08:00
parent a6f6211dde
commit 4cc442d7cd
4 changed files with 31 additions and 31 deletions

View File

@ -258,37 +258,37 @@ u32 AnalyzeCommand(const u8* data, DecodeMode mode)
void LoadCPReg(u32 subCmd, u32 value, CPMemory& cpMem)
{
switch (subCmd & 0xF0)
switch (subCmd & CP_COMMAND_MASK)
{
case 0x50:
case VCD_LO:
cpMem.vtxDesc.low.Hex = value;
break;
case 0x60:
case VCD_HI:
cpMem.vtxDesc.high.Hex = value;
break;
case 0x70:
ASSERT((subCmd & 0x0F) < 8);
cpMem.vtxAttr[subCmd & 7].g0.Hex = value;
case CP_VAT_REG_A:
ASSERT(subCmd - CP_VAT_REG_A < CP_NUM_VAT_REG);
cpMem.vtxAttr[subCmd & CP_VAT_MASK].g0.Hex = value;
break;
case 0x80:
ASSERT((subCmd & 0x0F) < 8);
cpMem.vtxAttr[subCmd & 7].g1.Hex = value;
case CP_VAT_REG_B:
ASSERT(subCmd - CP_VAT_REG_B < CP_NUM_VAT_REG);
cpMem.vtxAttr[subCmd & CP_VAT_MASK].g1.Hex = value;
break;
case 0x90:
ASSERT((subCmd & 0x0F) < 8);
cpMem.vtxAttr[subCmd & 7].g2.Hex = value;
case CP_VAT_REG_C:
ASSERT(subCmd - CP_VAT_REG_C < CP_NUM_VAT_REG);
cpMem.vtxAttr[subCmd & CP_VAT_MASK].g2.Hex = value;
break;
case 0xA0:
cpMem.arrayBases[subCmd & 0xF] = value;
case ARRAY_BASE:
cpMem.arrayBases[subCmd & CP_ARRAY_MASK] = value;
break;
case 0xB0:
cpMem.arrayStrides[subCmd & 0xF] = value & 0xFF;
case ARRAY_STRIDE:
cpMem.arrayStrides[subCmd & CP_ARRAY_MASK] = value & 0xFF;
break;
}
}

View File

@ -22,9 +22,9 @@ u32 AnalyzeCommand(const u8* data, DecodeMode mode);
struct CPMemory
{
TVtxDesc vtxDesc;
std::array<VAT, 8> vtxAttr;
std::array<u32, 16> arrayBases;
std::array<u32, 16> arrayStrides;
std::array<VAT, CP_NUM_VAT_REG> vtxAttr;
std::array<u32, CP_NUM_ARRAYS> arrayBases;
std::array<u32, CP_NUM_ARRAYS> arrayStrides;
};
void LoadCPReg(u32 subCmd, u32 value, CPMemory& cpMem);

View File

@ -25,14 +25,14 @@ void FifoPlaybackAnalyzer::AnalyzeFrames(FifoDataFile* file,
std::vector<AnalyzedFrameInfo>& frameInfo)
{
u32* cpMem = file->GetCPMem();
FifoAnalyzer::LoadCPReg(0x50, cpMem[0x50], s_CpMem);
FifoAnalyzer::LoadCPReg(0x60, cpMem[0x60], s_CpMem);
FifoAnalyzer::LoadCPReg(VCD_LO, cpMem[VCD_LO], s_CpMem);
FifoAnalyzer::LoadCPReg(VCD_HI, cpMem[VCD_HI], s_CpMem);
for (int i = 0; i < 8; ++i)
for (u32 i = 0; i < CP_NUM_VAT_REG; ++i)
{
FifoAnalyzer::LoadCPReg(0x70 + i, cpMem[0x70 + i], s_CpMem);
FifoAnalyzer::LoadCPReg(0x80 + i, cpMem[0x80 + i], s_CpMem);
FifoAnalyzer::LoadCPReg(0x90 + i, cpMem[0x90 + i], s_CpMem);
FifoAnalyzer::LoadCPReg(CP_VAT_REG_A + i, cpMem[CP_VAT_REG_A + i], s_CpMem);
FifoAnalyzer::LoadCPReg(CP_VAT_REG_B + i, cpMem[CP_VAT_REG_B + i], s_CpMem);
FifoAnalyzer::LoadCPReg(CP_VAT_REG_C + i, cpMem[CP_VAT_REG_C + i], s_CpMem);
}
frameInfo.clear();

View File

@ -17,16 +17,16 @@ void FifoRecordAnalyzer::Initialize(const u32* cpMem)
{
s_DrawingObject = false;
FifoAnalyzer::LoadCPReg(0x50, *(cpMem + 0x50), s_CpMem);
FifoAnalyzer::LoadCPReg(0x60, *(cpMem + 0x60), s_CpMem);
for (int i = 0; i < 8; ++i)
FifoAnalyzer::LoadCPReg(0x70 + i, *(cpMem + 0x70 + i), s_CpMem);
FifoAnalyzer::LoadCPReg(VCD_LO, cpMem[VCD_LO], s_CpMem);
FifoAnalyzer::LoadCPReg(VCD_HI, cpMem[VCD_HI], s_CpMem);
for (u32 i = 0; i < CP_NUM_VAT_REG; ++i)
FifoAnalyzer::LoadCPReg(CP_VAT_REG_A + i, cpMem[CP_VAT_REG_A + i], s_CpMem);
const u32* const bases_start = cpMem + 0xA0;
const u32* const bases_start = cpMem + ARRAY_BASE;
const u32* const bases_end = bases_start + s_CpMem.arrayBases.size();
std::copy(bases_start, bases_end, s_CpMem.arrayBases.begin());
const u32* const strides_start = cpMem + 0xB0;
const u32* const strides_start = cpMem + ARRAY_STRIDE;
const u32* const strides_end = strides_start + s_CpMem.arrayStrides.size();
std::copy(strides_start, strides_end, s_CpMem.arrayStrides.begin());
}