HW/MemoryInterface: Add data to savestates and initialize on boot.

This commit is contained in:
Lobsterzelda 2022-10-06 18:28:33 -04:00 committed by Admiral H. Curtiss
parent 973e58be60
commit d2db451eba
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB
4 changed files with 22 additions and 2 deletions

View File

@ -19,6 +19,7 @@
#include "Core/HW/GPFifo.h" #include "Core/HW/GPFifo.h"
#include "Core/HW/HSP/HSP.h" #include "Core/HW/HSP/HSP.h"
#include "Core/HW/Memmap.h" #include "Core/HW/Memmap.h"
#include "Core/HW/MemoryInterface.h"
#include "Core/HW/ProcessorInterface.h" #include "Core/HW/ProcessorInterface.h"
#include "Core/HW/SI/SI.h" #include "Core/HW/SI/SI.h"
#include "Core/HW/SystemTimers.h" #include "Core/HW/SystemTimers.h"
@ -45,6 +46,7 @@ void Init(const Sram* override_sram)
HSP::Init(); HSP::Init();
Memory::Init(); // Needs to be initialized before AddressSpace Memory::Init(); // Needs to be initialized before AddressSpace
AddressSpace::Init(); AddressSpace::Init();
MemoryInterface::Init();
DSP::Init(Config::Get(Config::MAIN_DSP_HLE)); DSP::Init(Config::Get(Config::MAIN_DSP_HLE));
DVDInterface::Init(); DVDInterface::Init();
GPFifo::Init(); GPFifo::Init();
@ -68,6 +70,7 @@ void Shutdown()
CPU::Shutdown(); CPU::Shutdown();
DVDInterface::Shutdown(); DVDInterface::Shutdown();
DSP::Shutdown(); DSP::Shutdown();
MemoryInterface::Shutdown();
AddressSpace::Shutdown(); AddressSpace::Shutdown();
Memory::Shutdown(); Memory::Shutdown();
HSP::Shutdown(); HSP::Shutdown();
@ -83,6 +86,8 @@ void DoState(PointerWrap& p)
{ {
Memory::DoState(p); Memory::DoState(p);
p.DoMarker("Memory"); p.DoMarker("Memory");
MemoryInterface::DoState(p);
p.DoMarker("MemoryInterface");
VideoInterface::DoState(p); VideoInterface::DoState(p);
p.DoMarker("VideoInterface"); p.DoMarker("VideoInterface");
SerialInterface::DoState(p); SerialInterface::DoState(p);

View File

@ -4,6 +4,8 @@
#include "Core/HW/MemoryInterface.h" #include "Core/HW/MemoryInterface.h"
#include <array> #include <array>
#include <cstring>
#include <type_traits>
#include "Common/BitField.h" #include "Common/BitField.h"
#include "Common/ChunkFile.h" #include "Common/ChunkFile.h"
@ -135,6 +137,17 @@ struct MIMemStruct
// STATE_TO_SAVE // STATE_TO_SAVE
static MIMemStruct g_mi_mem; static MIMemStruct g_mi_mem;
void Init()
{
static_assert(std::is_trivially_copyable_v<MIMemStruct>);
std::memset(&g_mi_mem, 0, sizeof(MIMemStruct));
}
void Shutdown()
{
Init();
}
void DoState(PointerWrap& p) void DoState(PointerWrap& p)
{ {
p.Do(g_mi_mem); p.Do(g_mi_mem);

View File

@ -13,7 +13,9 @@ class PointerWrap;
namespace MemoryInterface namespace MemoryInterface
{ {
void DoState(PointerWrap& p); void Init();
void Shutdown();
void DoState(PointerWrap& p);
void RegisterMMIO(MMIO::Mapping* mmio, u32 base); void RegisterMMIO(MMIO::Mapping* mmio, u32 base);
} // namespace MemoryInterface } // namespace MemoryInterface

View File

@ -94,7 +94,7 @@ static size_t s_state_writes_in_queue;
static std::condition_variable s_state_write_queue_is_empty; static std::condition_variable s_state_write_queue_is_empty;
// Don't forget to increase this after doing changes on the savestate system // Don't forget to increase this after doing changes on the savestate system
constexpr u32 STATE_VERSION = 150; // Last changed in PR 11124 constexpr u32 STATE_VERSION = 151; // Last changed in PR 11125
// Maps savestate versions to Dolphin versions. // Maps savestate versions to Dolphin versions.
// Versions after 42 don't need to be added to this list, // Versions after 42 don't need to be added to this list,