summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/XFStructs.cpp
diff options
context:
space:
mode:
authorPokechu22 <Pokechu022@gmail.com>2021-02-20 13:17:42 -0800
committerPokechu22 <Pokechu022@gmail.com>2021-05-07 15:42:26 -0700
commitdf77a687e891efdca38223c353da0d06bc666359 (patch)
treef585724198632a3a25b2d706564b16ebe9e2e445 /Source/Core/VideoCommon/XFStructs.cpp
parent1a3d2c32119e15d64008a94624e592cda70b734e (diff)
Add descriptions for GX_LOAD_INDX_A/B/C/D
Diffstat (limited to 'Source/Core/VideoCommon/XFStructs.cpp')
-rw-r--r--Source/Core/VideoCommon/XFStructs.cpp35
1 files changed, 28 insertions, 7 deletions
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<u32, u32, u32> 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<std::string, std::string> GetXFTransferInfo(const u8* data)
return std::make_pair(fmt::to_string(name), fmt::to_string(desc));
}
+
+std::pair<std::string, std::string> 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));
+}