yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::emu::render::SaveStateManager Class Reference

#include <save_state_manager.h>

Collaboration diagram for yaze::emu::render::SaveStateManager:

Classes

struct  CacheKey
 
struct  CacheKeyHash
 

Public Member Functions

 SaveStateManager (emu::Snes *snes, Rom *rom)
 
 ~SaveStateManager ()
 
absl::Status Initialize ()
 
absl::Status LoadState (StateType type, int context_id=0)
 
absl::Status GenerateRoomState (int room_id)
 
absl::Status GenerateAllBaselineStates ()
 
bool HasCachedState (StateType type, int context_id=0) const
 
absl::StatusOr< StateMetadataGetStateMetadata (StateType type, int context_id=0) const
 
absl::Status SaveStateToFile (const std::string &path, const StateMetadata &metadata)
 
absl::Status LoadStateFromFile (const std::string &path)
 
void SetStateDirectory (const std::string &path)
 
const std::string & GetStateDirectory () const
 
uint32_t CalculateRomChecksum () const
 

Private Member Functions

absl::Status BootToTitleScreen ()
 
absl::Status NavigateToFileSelect ()
 
absl::Status StartNewGame ()
 
absl::Status NavigateToRoom (int room_id)
 
void PressButton (int button, int frames=1)
 
void ReleaseAllButtons ()
 
void WaitFrames (int frames)
 
bool WaitForModule (uint8_t target, int max_frames)
 
absl::Status TeleportToRoomViaWram (int room_id)
 
absl::Status NavigateToRoomViaTas (int room_id)
 
uint8_t ReadWram (uint32_t addr)
 
uint16_t ReadWram16 (uint32_t addr)
 
int GetCurrentRoom ()
 
uint8_t GetGameModule ()
 
bool IsRoomFullyLoaded ()
 
std::string GetStatePath (StateType type, int context_id) const
 
std::string GetMetadataPath (StateType type, int context_id) const
 
bool IsStateCompatible (const StateMetadata &metadata) const
 

Private Attributes

emu::Snessnes_ = nullptr
 
Romrom_ = nullptr
 
std::string state_directory_
 
uint32_t rom_checksum_ = 0
 
std::unordered_map< CacheKey, StateMetadata, CacheKeyHashstate_cache_
 

Detailed Description

Definition at line 35 of file save_state_manager.h.

Constructor & Destructor Documentation

◆ SaveStateManager()

yaze::emu::render::SaveStateManager::SaveStateManager ( emu::Snes * snes,
Rom * rom )

Definition at line 56 of file save_state_manager.cc.

References state_directory_.

◆ ~SaveStateManager()

yaze::emu::render::SaveStateManager::~SaveStateManager ( )
default

Member Function Documentation

◆ Initialize()

absl::Status yaze::emu::render::SaveStateManager::Initialize ( )

Definition at line 64 of file save_state_manager.cc.

References CalculateRomChecksum(), rom_, rom_checksum_, snes_, and state_directory_.

Here is the call graph for this function:

◆ LoadState()

absl::Status yaze::emu::render::SaveStateManager::LoadState ( StateType type,
int context_id = 0 )

◆ GenerateRoomState()

◆ GenerateAllBaselineStates()

absl::Status yaze::emu::render::SaveStateManager::GenerateAllBaselineStates ( )

Definition at line 146 of file save_state_manager.cc.

References GenerateRoomState().

Here is the call graph for this function:

◆ HasCachedState()

bool yaze::emu::render::SaveStateManager::HasCachedState ( StateType type,
int context_id = 0 ) const

Definition at line 174 of file save_state_manager.cc.

References GetStatePath().

Here is the call graph for this function:

◆ GetStateMetadata()

absl::StatusOr< StateMetadata > yaze::emu::render::SaveStateManager::GetStateMetadata ( StateType type,
int context_id = 0 ) const

◆ SaveStateToFile()

absl::Status yaze::emu::render::SaveStateManager::SaveStateToFile ( const std::string & path,
const StateMetadata & metadata )

◆ LoadStateFromFile()

absl::Status yaze::emu::render::SaveStateManager::LoadStateFromFile ( const std::string & path)

Definition at line 255 of file save_state_manager.cc.

References yaze::emu::Snes::loadState(), and snes_.

Referenced by LoadState().

Here is the call graph for this function:

◆ SetStateDirectory()

void yaze::emu::render::SaveStateManager::SetStateDirectory ( const std::string & path)
inline

Definition at line 69 of file save_state_manager.h.

References state_directory_.

◆ GetStateDirectory()

const std::string & yaze::emu::render::SaveStateManager::GetStateDirectory ( ) const
inline

Definition at line 70 of file save_state_manager.h.

References state_directory_.

◆ CalculateRomChecksum()

uint32_t yaze::emu::render::SaveStateManager::CalculateRomChecksum ( ) const

Definition at line 264 of file save_state_manager.cc.

References yaze::emu::render::CalculateCRC32(), yaze::Rom::data(), yaze::Rom::is_loaded(), rom_, and yaze::Rom::size().

Referenced by Initialize().

Here is the call graph for this function:

◆ BootToTitleScreen()

absl::Status yaze::emu::render::SaveStateManager::BootToTitleScreen ( )
private

◆ NavigateToFileSelect()

absl::Status yaze::emu::render::SaveStateManager::NavigateToFileSelect ( )
private

Definition at line 319 of file save_state_manager.cc.

References GetGameModule(), yaze::emu::render::buttons::kStart, yaze::emu::Snes::RunFrame(), yaze::emu::Snes::SetButtonState(), and snes_.

Referenced by GenerateRoomState().

Here is the call graph for this function:

◆ StartNewGame()

absl::Status yaze::emu::render::SaveStateManager::StartNewGame ( )
private

◆ NavigateToRoom()

absl::Status yaze::emu::render::SaveStateManager::NavigateToRoom ( int room_id)
private

Definition at line 422 of file save_state_manager.cc.

References NavigateToRoomViaTas(), and TeleportToRoomViaWram().

Referenced by GenerateRoomState().

Here is the call graph for this function:

◆ PressButton()

void yaze::emu::render::SaveStateManager::PressButton ( int button,
int frames = 1 )
private

Definition at line 504 of file save_state_manager.cc.

References yaze::emu::Snes::RunFrame(), yaze::emu::Snes::SetButtonState(), and snes_.

Here is the call graph for this function:

◆ ReleaseAllButtons()

◆ WaitFrames()

void yaze::emu::render::SaveStateManager::WaitFrames ( int frames)
private

Definition at line 521 of file save_state_manager.cc.

References yaze::emu::Snes::RunFrame(), and snes_.

Here is the call graph for this function:

◆ WaitForModule()

bool yaze::emu::render::SaveStateManager::WaitForModule ( uint8_t target,
int max_frames )
private

Definition at line 543 of file save_state_manager.cc.

References GetGameModule(), yaze::emu::Snes::RunFrame(), and snes_.

Here is the call graph for this function:

◆ TeleportToRoomViaWram()

absl::Status yaze::emu::render::SaveStateManager::TeleportToRoomViaWram ( int room_id)
private

◆ NavigateToRoomViaTas()

absl::Status yaze::emu::render::SaveStateManager::NavigateToRoomViaTas ( int room_id)
private

Definition at line 481 of file save_state_manager.cc.

References GetCurrentRoom(), IsRoomFullyLoaded(), yaze::emu::Snes::RunFrame(), and snes_.

Referenced by NavigateToRoom().

Here is the call graph for this function:

◆ ReadWram()

uint8_t yaze::emu::render::SaveStateManager::ReadWram ( uint32_t addr)
private

Definition at line 527 of file save_state_manager.cc.

References yaze::emu::Snes::Read(), and snes_.

Referenced by GetGameModule(), IsRoomFullyLoaded(), and TeleportToRoomViaWram().

Here is the call graph for this function:

◆ ReadWram16()

uint16_t yaze::emu::render::SaveStateManager::ReadWram16 ( uint32_t addr)
private

Definition at line 531 of file save_state_manager.cc.

References yaze::emu::Snes::Read(), and snes_.

Referenced by GetCurrentRoom().

Here is the call graph for this function:

◆ GetCurrentRoom()

int yaze::emu::render::SaveStateManager::GetCurrentRoom ( )
private

Definition at line 535 of file save_state_manager.cc.

References yaze::emu::render::wram_addresses::kRoomId, and ReadWram16().

Referenced by NavigateToRoomViaTas(), and TeleportToRoomViaWram().

Here is the call graph for this function:

◆ GetGameModule()

uint8_t yaze::emu::render::SaveStateManager::GetGameModule ( )
private

◆ IsRoomFullyLoaded()

bool yaze::emu::render::SaveStateManager::IsRoomFullyLoaded ( )
private

Definition at line 553 of file save_state_manager.cc.

References ReadWram().

Referenced by NavigateToRoomViaTas(), and TeleportToRoomViaWram().

Here is the call graph for this function:

◆ GetStatePath()

std::string yaze::emu::render::SaveStateManager::GetStatePath ( StateType type,
int context_id ) const
private

◆ GetMetadataPath()

std::string yaze::emu::render::SaveStateManager::GetMetadataPath ( StateType type,
int context_id ) const
private

Definition at line 581 of file save_state_manager.cc.

References GetStatePath().

Referenced by GetStateMetadata(), and LoadState().

Here is the call graph for this function:

◆ IsStateCompatible()

bool yaze::emu::render::SaveStateManager::IsStateCompatible ( const StateMetadata & metadata) const
private

Definition at line 586 of file save_state_manager.cc.

References yaze::emu::render::StateMetadata::rom_checksum, and rom_checksum_.

Referenced by LoadState().

Member Data Documentation

◆ snes_

◆ rom_

Rom* yaze::emu::render::SaveStateManager::rom_ = nullptr
private

Definition at line 107 of file save_state_manager.h.

Referenced by CalculateRomChecksum(), and Initialize().

◆ state_directory_

std::string yaze::emu::render::SaveStateManager::state_directory_
private

◆ rom_checksum_

uint32_t yaze::emu::render::SaveStateManager::rom_checksum_ = 0
private

Definition at line 110 of file save_state_manager.h.

Referenced by GenerateRoomState(), Initialize(), and IsStateCompatible().

◆ state_cache_

std::unordered_map<CacheKey, StateMetadata, CacheKeyHash> yaze::emu::render::SaveStateManager::state_cache_
private

Definition at line 126 of file save_state_manager.h.


The documentation for this class was generated from the following files: