From df77a687e891efdca38223c353da0d06bc666359 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Sat, 20 Feb 2021 13:17:42 -0800 Subject: Add descriptions for GX_LOAD_INDX_A/B/C/D --- Source/Core/VideoCommon/XFStructs.cpp | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) (limited to 'Source/Core/VideoCommon/XFStructs.cpp') diff --git a/Source/Core/VideoCommon/XFStructs.cpp b/Source/Core/VideoCommon/XFStructs.cpp index 9ceaf2edc1..4da229c422 100644 --- a/Source/Core/VideoCommon/XFStructs.cpp +++ b/Source/Core/VideoCommon/XFStructs.cpp @@ -259,12 +259,19 @@ void LoadXFReg(u32 transferSize, u32 baseAddress, DataReader src) } } +constexpr std::tuple ExtractIndexedXF(u32 val) +{ + const u32 index = val >> 16; + const u32 address = val & 0xFFF; // check mask + const u32 size = ((val >> 12) & 0xF) + 1; + + return {index, address, size}; +} + // TODO - verify that it is correct. Seems to work, though. void LoadIndexedXF(u32 val, int refarray) { - int index = val >> 16; - int address = val & 0xFFF; // check mask - int size = ((val >> 12) & 0xF) + 1; + const auto [index, address, size] = ExtractIndexedXF(val); // load stuff from array to address in xf mem u32* currData = (u32*)(&xfmem) + address; @@ -279,7 +286,7 @@ void LoadIndexedXF(u32 val, int refarray) g_main_cp_state.array_strides[refarray] * index); } bool changed = false; - for (int i = 0; i < size; ++i) + for (u32 i = 0; i < size; ++i) { if (currData[i] != Common::swap32(newData[i])) { @@ -290,15 +297,14 @@ void LoadIndexedXF(u32 val, int refarray) } if (changed) { - for (int i = 0; i < size; ++i) + for (u32 i = 0; i < size; ++i) currData[i] = Common::swap32(newData[i]); } } void PreprocessIndexedXF(u32 val, int refarray) { - const u32 index = val >> 16; - const u32 size = ((val >> 12) & 0xF) + 1; + const auto [index, address, size] = ExtractIndexedXF(val); const u8* new_data = Memory::GetPointer(g_preprocess_cp_state.array_bases[refarray] + g_preprocess_cp_state.array_strides[refarray] * index); @@ -643,3 +649,18 @@ std::pair GetXFTransferInfo(const u8* data) return std::make_pair(fmt::to_string(name), fmt::to_string(desc)); } + +std::pair GetXFIndexedLoadInfo(u8 array, u32 value) +{ + const auto [index, address, size] = ExtractIndexedXF(value); + + const auto desc = fmt::format("Load {} bytes to XF address {:03x} from CP array {} row {}", size, + address, array, index); + fmt::memory_buffer written; + for (u32 i = 0; i < size; i++) + { + fmt::format_to(written, "{}\n", GetXFMemName(address + i)); + } + + return std::make_pair(desc, fmt::to_string(written)); +} -- cgit v1.2.3