1 // Copyright 2011 Dolphin Emulator Project 2 // Licensed under GPLv2+ 3 // Refer to the license.txt file included. 4 5 #pragma once 6 7 #include <memory> 8 #include <string> 9 #include <vector> 10 11 #include "Common/CommonTypes.h" 12 #include "VideoCommon/XFMemory.h" 13 14 namespace File 15 { 16 class IOFile; 17 } 18 19 struct MemoryUpdate 20 { 21 enum Type 22 { 23 TEXTURE_MAP = 0x01, 24 XF_DATA = 0x02, 25 VERTEX_STREAM = 0x04, 26 TMEM = 0x08, 27 }; 28 29 u32 fifoPosition; 30 u32 address; 31 std::vector<u8> data; 32 Type type; 33 }; 34 35 struct FifoFrameInfo 36 { 37 std::vector<u8> fifoData; 38 39 u32 fifoStart; 40 u32 fifoEnd; 41 42 // Must be sorted by fifoPosition 43 std::vector<MemoryUpdate> memoryUpdates; 44 }; 45 46 class FifoDataFile 47 { 48 public: 49 enum 50 { 51 BP_MEM_SIZE = 256, 52 CP_MEM_SIZE = 256, 53 XF_MEM_SIZE = 4096, 54 XF_REGS_SIZE = 88, 55 TEX_MEM_SIZE = 1024 * 1024, 56 }; 57 static_assert((XF_MEM_SIZE + XF_REGS_SIZE) * sizeof(u32) == sizeof(XFMemory)); 58 59 FifoDataFile(); 60 ~FifoDataFile(); 61 62 void SetIsWii(bool isWii); 63 bool GetIsWii() const; 64 bool HasBrokenEFBCopies() const; 65 bool ShouldGenerateFakeVIUpdates() const; 66 GetBPMem()67 u32* GetBPMem() { return m_BPMem; } GetCPMem()68 u32* GetCPMem() { return m_CPMem; } GetXFMem()69 u32* GetXFMem() { return m_XFMem; } GetXFRegs()70 u32* GetXFRegs() { return m_XFRegs; } GetTexMem()71 u8* GetTexMem() { return m_TexMem; } GetRamSizeReal()72 u32 GetRamSizeReal() { return m_ram_size_real; } GetExRamSizeReal()73 u32 GetExRamSizeReal() { return m_exram_size_real; } 74 75 void AddFrame(const FifoFrameInfo& frameInfo); GetFrame(u32 frame)76 const FifoFrameInfo& GetFrame(u32 frame) const { return m_Frames[frame]; } GetFrameCount()77 u32 GetFrameCount() const { return static_cast<u32>(m_Frames.size()); } 78 bool Save(const std::string& filename); 79 80 static std::unique_ptr<FifoDataFile> Load(const std::string& filename, bool flagsOnly); 81 82 private: 83 enum 84 { 85 FLAG_IS_WII = 1 86 }; 87 88 void PadFile(size_t numBytes, File::IOFile& file); 89 90 void SetFlag(u32 flag, bool set); 91 bool GetFlag(u32 flag) const; 92 93 u64 WriteMemoryUpdates(const std::vector<MemoryUpdate>& memUpdates, File::IOFile& file); 94 static void ReadMemoryUpdates(u64 fileOffset, u32 numUpdates, 95 std::vector<MemoryUpdate>& memUpdates, File::IOFile& file); 96 97 u32 m_BPMem[BP_MEM_SIZE]; 98 u32 m_CPMem[CP_MEM_SIZE]; 99 u32 m_XFMem[XF_MEM_SIZE]; 100 u32 m_XFRegs[XF_REGS_SIZE]; 101 u8 m_TexMem[TEX_MEM_SIZE]; 102 u32 m_ram_size_real; 103 u32 m_exram_size_real; 104 105 u32 m_Flags = 0; 106 u32 m_Version = 0; 107 108 std::vector<FifoFrameInfo> m_Frames; 109 }; 110