Make parameters, arguments etc. constant

This commit is contained in:
Dr. Dystopia 2025-03-25 22:52:32 +01:00
parent 18979129f3
commit e7a95f082d

View file

@ -46,7 +46,7 @@ FIFOAnalyzer::FIFOAnalyzer(FifoPlayer& fifo_player) : m_fifo_player(fifo_player)
UpdateTree(); UpdateTree();
auto& settings = Settings::GetQSettings(); const auto& settings = Settings::GetQSettings();
m_object_splitter->restoreState( m_object_splitter->restoreState(
settings.value(QStringLiteral("fifoanalyzer/objectsplitter")).toByteArray()); settings.value(QStringLiteral("fifoanalyzer/objectsplitter")).toByteArray());
@ -146,7 +146,7 @@ void FIFOAnalyzer::UpdateTree()
m_tree_widget->addTopLevelItem(recording_item); m_tree_widget->addTopLevelItem(recording_item);
auto* file = m_fifo_player.GetFile(); const auto* file = m_fifo_player.GetFile();
const u32 frame_count = file->GetFrameCount(); const u32 frame_count = file->GetFrameCount();
@ -201,9 +201,9 @@ namespace
class DetailCallback : public OpcodeDecoder::Callback class DetailCallback : public OpcodeDecoder::Callback
{ {
public: public:
explicit DetailCallback(CPState cpmem) : m_cpmem(cpmem) {} explicit DetailCallback(const CPState& cpmem) : m_cpmem(cpmem) {}
OPCODE_CALLBACK(void OnCP(u8 command, u32 value)) OPCODE_CALLBACK(void OnCP(const u8 command, const u32 value))
{ {
// Note: No need to update m_cpmem as it already has the final value for this object // Note: No need to update m_cpmem as it already has the final value for this object
@ -216,7 +216,7 @@ public:
.arg(QString::fromStdString(name)); .arg(QString::fromStdString(name));
} }
OPCODE_CALLBACK(void OnXF(u16 address, u8 count, const u8* data)) OPCODE_CALLBACK(void OnXF(const u16 address, const u8 count, const u8* data))
{ {
const auto [name, desc] = GetXFTransferInfo(address, count, data); const auto [name, desc] = GetXFTransferInfo(address, count, data);
ASSERT(!name.empty()); ASSERT(!name.empty());
@ -235,7 +235,7 @@ public:
text += QStringLiteral(" ") + QString::fromStdString(name); text += QStringLiteral(" ") + QString::fromStdString(name);
} }
OPCODE_CALLBACK(void OnBP(u8 command, u32 value)) OPCODE_CALLBACK(void OnBP(const u8 command, const u32 value))
{ {
const auto [name, desc] = GetBPRegInfo(command, value); const auto [name, desc] = GetBPRegInfo(command, value);
ASSERT(!name.empty()); ASSERT(!name.empty());
@ -245,15 +245,17 @@ public:
.arg(value, 6, 16, QLatin1Char('0')) .arg(value, 6, 16, QLatin1Char('0'))
.arg(QString::fromStdString(name)); .arg(QString::fromStdString(name));
} }
OPCODE_CALLBACK(void OnIndexedLoad(CPArray array, u32 index, u16 address, u8 size)) OPCODE_CALLBACK(void OnIndexedLoad(const CPArray array, const u32 index, const u16 address,
const u8 size))
{ {
const auto [desc, written] = GetXFIndexedLoadInfo(array, index, address, size); const auto [desc, written] = GetXFIndexedLoadInfo(array, index, address, size);
text = QStringLiteral("LOAD INDX %1 %2") text = QStringLiteral("LOAD INDX %1 %2")
.arg(QString::fromStdString(fmt::to_string(array))) .arg(QString::fromStdString(fmt::to_string(array)))
.arg(QString::fromStdString(desc)); .arg(QString::fromStdString(desc));
} }
OPCODE_CALLBACK(void OnPrimitiveCommand(OpcodeDecoder::Primitive primitive, u8 vat, OPCODE_CALLBACK(void OnPrimitiveCommand(const OpcodeDecoder::Primitive primitive, const u8 vat,
u32 vertex_size, u16 num_vertices, const u8* vertex_data)) const u32 vertex_size, const u16 num_vertices,
const u8* vertex_data))
{ {
const auto name = fmt::to_string(primitive); const auto name = fmt::to_string(primitive);
@ -283,14 +285,14 @@ public:
#endif #endif
} }
OPCODE_CALLBACK(void OnDisplayList(u32 address, u32 size)) OPCODE_CALLBACK(void OnDisplayList(const u32 address, const u32 size))
{ {
text = QObject::tr("Call display list at %1 with size %2") text = QObject::tr("Call display list at %1 with size %2")
.arg(address, 8, 16, QLatin1Char('0')) .arg(address, 8, 16, QLatin1Char('0'))
.arg(size, 8, 16, QLatin1Char('0')); .arg(size, 8, 16, QLatin1Char('0'));
} }
OPCODE_CALLBACK(void OnNop(u32 count)) OPCODE_CALLBACK(void OnNop(const u32 count))
{ {
if (count > 1) if (count > 1)
text = QStringLiteral("NOP (%1x)").arg(count); text = QStringLiteral("NOP (%1x)").arg(count);
@ -313,7 +315,7 @@ public:
OPCODE_CALLBACK(CPState& GetCPState()) { return m_cpmem; } OPCODE_CALLBACK(CPState& GetCPState()) { return m_cpmem; }
OPCODE_CALLBACK(u32 GetVertexSize(u8 vat)) OPCODE_CALLBACK(u32 GetVertexSize(const u8 vat))
{ {
return VertexLoaderBase::GetVertexSize(GetCPState().vtx_desc, GetCPState().vtx_attr[vat]); return VertexLoaderBase::GetVertexSize(GetCPState().vtx_desc, GetCPState().vtx_attr[vat]);
} }
@ -472,7 +474,7 @@ void FIFOAnalyzer::FindNext()
const int index = m_detail_list->currentRow(); const int index = m_detail_list->currentRow();
ASSERT(index >= 0); ASSERT(index >= 0);
auto next_result = std::ranges::find_if( const auto next_result = std::ranges::find_if(
m_search_results, [index](auto& result) { return result.m_cmd > static_cast<u32>(index); }); m_search_results, [index](auto& result) { return result.m_cmd > static_cast<u32>(index); });
if (next_result != m_search_results.end()) if (next_result != m_search_results.end())
{ {
@ -485,7 +487,7 @@ void FIFOAnalyzer::FindPrevious()
const int index = m_detail_list->currentRow(); const int index = m_detail_list->currentRow();
ASSERT(index >= 0); ASSERT(index >= 0);
auto prev_result = const auto prev_result =
std::ranges::find_if(m_search_results | std::views::reverse, [index](auto& result) { std::ranges::find_if(m_search_results | std::views::reverse, [index](auto& result) {
return result.m_cmd < static_cast<u32>(index); return result.m_cmd < static_cast<u32>(index);
}); });
@ -495,7 +497,7 @@ void FIFOAnalyzer::FindPrevious()
} }
} }
void FIFOAnalyzer::ShowSearchResult(size_t index) void FIFOAnalyzer::ShowSearchResult(const size_t index)
{ {
if (m_search_results.empty()) if (m_search_results.empty())
return; return;
@ -526,7 +528,7 @@ class DescriptionCallback : public OpcodeDecoder::Callback
public: public:
explicit DescriptionCallback(const CPState& cpmem) : m_cpmem(cpmem) {} explicit DescriptionCallback(const CPState& cpmem) : m_cpmem(cpmem) {}
OPCODE_CALLBACK(void OnBP(u8 command, u32 value)) OPCODE_CALLBACK(void OnBP(const u8 command, const u32 value))
{ {
const auto [name, desc] = GetBPRegInfo(command, value); const auto [name, desc] = GetBPRegInfo(command, value);
ASSERT(!name.empty()); ASSERT(!name.empty());
@ -541,7 +543,7 @@ public:
text += QString::fromStdString(desc); text += QString::fromStdString(desc);
} }
OPCODE_CALLBACK(void OnCP(u8 command, u32 value)) OPCODE_CALLBACK(void OnCP(const u8 command, const u32 value))
{ {
// Note: No need to update m_cpmem as it already has the final value for this object // Note: No need to update m_cpmem as it already has the final value for this object
@ -558,7 +560,7 @@ public:
text += QString::fromStdString(desc); text += QString::fromStdString(desc);
} }
OPCODE_CALLBACK(void OnXF(u16 address, u8 count, const u8* data)) OPCODE_CALLBACK(void OnXF(const u16 address, const u8 count, const u8* data))
{ {
const auto [name, desc] = GetXFTransferInfo(address, count, data); const auto [name, desc] = GetXFTransferInfo(address, count, data);
ASSERT(!name.empty()); ASSERT(!name.empty());
@ -573,7 +575,8 @@ public:
text += QString::fromStdString(desc); text += QString::fromStdString(desc);
} }
OPCODE_CALLBACK(void OnIndexedLoad(CPArray array, u32 index, u16 address, u8 size)) OPCODE_CALLBACK(void OnIndexedLoad(const CPArray array, const u32 index, const u16 address,
const u8 size))
{ {
const auto [desc, written] = GetXFIndexedLoadInfo(array, index, address, size); const auto [desc, written] = GetXFIndexedLoadInfo(array, index, address, size);
@ -605,7 +608,8 @@ public:
} }
OPCODE_CALLBACK(void OnPrimitiveCommand(OpcodeDecoder::Primitive primitive, u8 vat, OPCODE_CALLBACK(void OnPrimitiveCommand(OpcodeDecoder::Primitive primitive, u8 vat,
u32 vertex_size, u16 num_vertices, const u8* vertex_data)) const u32 vertex_size, const u16 num_vertices,
const u8* vertex_data))
{ {
const auto name = fmt::format("{} VAT {}", primitive, vat); const auto name = fmt::format("{} VAT {}", primitive, vat);
@ -618,8 +622,8 @@ public:
const auto& vtx_attr = m_cpmem.vtx_attr[vat]; const auto& vtx_attr = m_cpmem.vtx_attr[vat];
u32 i = 0; u32 i = 0;
const auto process_component = [&](VertexComponentFormat cformat, ComponentFormat format, const auto process_component = [&](const VertexComponentFormat cformat, ComponentFormat format,
u32 non_indexed_count, u32 indexed_count = 1) { const u32 non_indexed_count, const u32 indexed_count = 1) {
u32 count; u32 count;
if (cformat == VertexComponentFormat::NotPresent) if (cformat == VertexComponentFormat::NotPresent)
return; return;
@ -655,7 +659,7 @@ public:
} }
text += QLatin1Char{' '}; text += QLatin1Char{' '};
}; };
const auto process_simple_component = [&](u32 size) { const auto process_simple_component = [&](const u32 size) {
for (u32 component_off = 0; component_off < size; component_off++) for (u32 component_off = 0; component_off < size; component_off++)
{ {
text += QStringLiteral("%1").arg(vertex_data[i + component_off], 2, 16, QLatin1Char('0')); text += QStringLiteral("%1").arg(vertex_data[i + component_off], 2, 16, QLatin1Char('0'));
@ -733,7 +737,7 @@ public:
OPCODE_CALLBACK(CPState& GetCPState()) { return m_cpmem; } OPCODE_CALLBACK(CPState& GetCPState()) { return m_cpmem; }
OPCODE_CALLBACK(u32 GetVertexSize(u8 vat)) OPCODE_CALLBACK(u32 GetVertexSize(const u8 vat))
{ {
return VertexLoaderBase::GetVertexSize(GetCPState().vtx_desc, GetCPState().vtx_attr[vat]); return VertexLoaderBase::GetVertexSize(GetCPState().vtx_desc, GetCPState().vtx_attr[vat]);
} }