Refactor OpcodeDecoding and FIFO analyzer to use callbacks

This commit is contained in:
Pokechu22
2021-04-22 20:57:56 -07:00
parent 0441826206
commit b5fd35f951
29 changed files with 1214 additions and 1388 deletions

View File

@ -5,6 +5,7 @@
#include <array>
#include <string>
#include <type_traits>
#include <utility>
#include "Common/BitField.h"
@ -630,13 +631,21 @@ class VertexLoaderBase;
// STATE_TO_SAVE
struct CPState final
{
CPState() = default;
explicit CPState(const u32* memory);
// Mutates the CP state based on the given command and value.
void LoadCPReg(u8 sub_cmd, u32 value);
// Fills memory with data from CP regs. There should be space for 0x100 values in memory.
void FillCPMemoryArray(u32* memory) const;
Common::EnumMap<u32, CPArray::XF_D> array_bases;
Common::EnumMap<u32, CPArray::XF_D> array_strides;
TMatrixIndexA matrix_index_a{};
TMatrixIndexB matrix_index_b{};
TVtxDesc vtx_desc;
// Most games only use the first VtxAttr and simply reconfigure it all the time as needed.
VAT vtx_attr[CP_NUM_VAT_REG]{};
std::array<VAT, CP_NUM_VAT_REG> vtx_attr{};
// Attributes that actually belong to VertexLoaderManager:
BitSet32 attr_dirty{};
@ -644,18 +653,13 @@ struct CPState final
VertexLoaderBase* vertex_loaders[CP_NUM_VAT_REG]{};
int last_id = 0;
};
static_assert(std::is_trivially_copyable_v<CPState>);
class PointerWrap;
extern CPState g_main_cp_state;
extern CPState g_preprocess_cp_state;
// Might move this into its own file later.
void LoadCPReg(u32 SubCmd, u32 Value, bool is_preprocess = false);
// Fills memory with data from CP regs
void FillCPMemoryArray(u32* memory);
void DoCPState(PointerWrap& p);
void CopyPreprocessCPStateFromMain();