mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-09-13 15:03:01 -06:00

Changed several enums from Memmap.h to be static vars and implemented Get functions to query them. This seems to have boosted speed a bit in some titles? The new variables and some previously statically initialized items are now initialized via Memory::Init() and the new AddressSpace::Init(). s_ram_size_real and the new s_exram_size_real in particular are initialized from new OnionConfig values "MAIN_MEM1_SIZE" and "MAIN_MEM2_SIZE", only if "MAIN_RAM_OVERRIDE_ENABLE" is true. GUI features have been added to Config > Advanced to adjust the new OnionConfig values. A check has been added to State::doState to ensure savestates with memory configurations different from the current settings aren't loaded. The STATE_VERSION is now 115. FIFO Files have been updated from version 4 to version 5, now including the MEM1 and MEM2 sizes from the time of DFF creation. FIFO Logs not using the new features (OnionConfig MAIN_RAM_OVERRIDE_ENABLE is false) are still backwards compatible. FIFO Logs that do use the new features have a MIN_LOADER_VERSION of 5. Thanks to the order of function calls, FIFO logs are able to automatically configure the new OnionConfig settings to match what is needed. This is a bit hacky, though, so I also threw in a failsafe for if the conditions that allow this to work ever go away. I took the liberty of adding a log message to explain why the core fails to initialize if the MIN_LOADER_VERSION is too great. Some IOS code has had the function "RAMOverrideForIOSMemoryValues" appended to it to recalculate IOS Memory Values from retail IOSes/apploaders to fit the extended memory sizes. Worry not, if MAIN_RAM_OVERRIDE_ENABLE is false, this function does absolutely nothing. A hotfix in DolphinQt/MenuBar.cpp has been implemented for RAM Override.
110 lines
2.4 KiB
C++
110 lines
2.4 KiB
C++
// Copyright 2011 Dolphin Emulator Project
|
|
// Licensed under GPLv2+
|
|
// Refer to the license.txt file included.
|
|
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "Common/CommonTypes.h"
|
|
#include "VideoCommon/XFMemory.h"
|
|
|
|
namespace File
|
|
{
|
|
class IOFile;
|
|
}
|
|
|
|
struct MemoryUpdate
|
|
{
|
|
enum Type
|
|
{
|
|
TEXTURE_MAP = 0x01,
|
|
XF_DATA = 0x02,
|
|
VERTEX_STREAM = 0x04,
|
|
TMEM = 0x08,
|
|
};
|
|
|
|
u32 fifoPosition;
|
|
u32 address;
|
|
std::vector<u8> data;
|
|
Type type;
|
|
};
|
|
|
|
struct FifoFrameInfo
|
|
{
|
|
std::vector<u8> fifoData;
|
|
|
|
u32 fifoStart;
|
|
u32 fifoEnd;
|
|
|
|
// Must be sorted by fifoPosition
|
|
std::vector<MemoryUpdate> memoryUpdates;
|
|
};
|
|
|
|
class FifoDataFile
|
|
{
|
|
public:
|
|
enum
|
|
{
|
|
BP_MEM_SIZE = 256,
|
|
CP_MEM_SIZE = 256,
|
|
XF_MEM_SIZE = 4096,
|
|
XF_REGS_SIZE = 88,
|
|
TEX_MEM_SIZE = 1024 * 1024,
|
|
};
|
|
static_assert((XF_MEM_SIZE + XF_REGS_SIZE) * sizeof(u32) == sizeof(XFMemory));
|
|
|
|
FifoDataFile();
|
|
~FifoDataFile();
|
|
|
|
void SetIsWii(bool isWii);
|
|
bool GetIsWii() const;
|
|
bool HasBrokenEFBCopies() const;
|
|
bool ShouldGenerateFakeVIUpdates() const;
|
|
|
|
u32* GetBPMem() { return m_BPMem; }
|
|
u32* GetCPMem() { return m_CPMem; }
|
|
u32* GetXFMem() { return m_XFMem; }
|
|
u32* GetXFRegs() { return m_XFRegs; }
|
|
u8* GetTexMem() { return m_TexMem; }
|
|
u32 GetRamSizeReal() { return m_ram_size_real; }
|
|
u32 GetExRamSizeReal() { return m_exram_size_real; }
|
|
|
|
void AddFrame(const FifoFrameInfo& frameInfo);
|
|
const FifoFrameInfo& GetFrame(u32 frame) const { return m_Frames[frame]; }
|
|
u32 GetFrameCount() const { return static_cast<u32>(m_Frames.size()); }
|
|
bool Save(const std::string& filename);
|
|
|
|
static std::unique_ptr<FifoDataFile> Load(const std::string& filename, bool flagsOnly);
|
|
|
|
private:
|
|
enum
|
|
{
|
|
FLAG_IS_WII = 1
|
|
};
|
|
|
|
void PadFile(size_t numBytes, File::IOFile& file);
|
|
|
|
void SetFlag(u32 flag, bool set);
|
|
bool GetFlag(u32 flag) const;
|
|
|
|
u64 WriteMemoryUpdates(const std::vector<MemoryUpdate>& memUpdates, File::IOFile& file);
|
|
static void ReadMemoryUpdates(u64 fileOffset, u32 numUpdates,
|
|
std::vector<MemoryUpdate>& memUpdates, File::IOFile& file);
|
|
|
|
u32 m_BPMem[BP_MEM_SIZE];
|
|
u32 m_CPMem[CP_MEM_SIZE];
|
|
u32 m_XFMem[XF_MEM_SIZE];
|
|
u32 m_XFRegs[XF_REGS_SIZE];
|
|
u8 m_TexMem[TEX_MEM_SIZE];
|
|
u32 m_ram_size_real;
|
|
u32 m_exram_size_real;
|
|
|
|
u32 m_Flags = 0;
|
|
u32 m_Version = 0;
|
|
|
|
std::vector<FifoFrameInfo> m_Frames;
|
|
};
|