mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-21 09:49:01 +00:00
fix: drill down system as needed and use GetInstance when necessary
This commit is contained in:
parent
340a8df17f
commit
e6032f1eb9
9 changed files with 37 additions and 34 deletions
|
@ -2569,7 +2569,7 @@ void CEXISlippi::prepareFileLength(u8* payload)
|
||||||
std::string file_name((char*)&payload[0]);
|
std::string file_name((char*)&payload[0]);
|
||||||
|
|
||||||
std::string contents;
|
std::string contents;
|
||||||
u32 size = game_file_loader->LoadFile(file_name, contents);
|
u32 size = game_file_loader->LoadFile(this->m_system, file_name, contents);
|
||||||
|
|
||||||
INFO_LOG_FMT(SLIPPI, "Getting file size for: {} -> {}", file_name.c_str(), size);
|
INFO_LOG_FMT(SLIPPI, "Getting file size for: {} -> {}", file_name.c_str(), size);
|
||||||
|
|
||||||
|
@ -2584,7 +2584,7 @@ void CEXISlippi::prepareFileLoad(u8* payload)
|
||||||
std::string file_name((char*)&payload[0]);
|
std::string file_name((char*)&payload[0]);
|
||||||
|
|
||||||
std::string contents;
|
std::string contents;
|
||||||
u32 size = game_file_loader->LoadFile(file_name, contents);
|
u32 size = game_file_loader->LoadFile(this->m_system, file_name, contents);
|
||||||
std::vector<u8> buf(contents.begin(), contents.end());
|
std::vector<u8> buf(contents.begin(), contents.end());
|
||||||
|
|
||||||
INFO_LOG_FMT(SLIPPI, "Writing file contents: {} -> {}", file_name.c_str(), size);
|
INFO_LOG_FMT(SLIPPI, "Writing file contents: {} -> {}", file_name.c_str(), size);
|
||||||
|
@ -3078,7 +3078,7 @@ void CEXISlippi::DMAWrite(u32 _uAddr, u32 _uSize)
|
||||||
{
|
{
|
||||||
auto& system = Core::System::GetInstance();
|
auto& system = Core::System::GetInstance();
|
||||||
auto& memory = system.GetMemory();
|
auto& memory = system.GetMemory();
|
||||||
u8* mem_ptr = memory.GetPointer(_uAddr);
|
u8* mem_ptr = memory.GetPointerForRange(_uAddr, _uSize);
|
||||||
|
|
||||||
u32 buf_loc = 0;
|
u32 buf_loc = 0;
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ std::string getFilePath(std::string file_name)
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 SlippiGameFileLoader::LoadFile(std::string file_name, std::string& data)
|
u32 SlippiGameFileLoader::LoadFile(Core::System& system, std::string file_name, std::string& data)
|
||||||
{
|
{
|
||||||
if (file_cache.count(file_name))
|
if (file_cache.count(file_name))
|
||||||
{
|
{
|
||||||
|
@ -53,7 +53,7 @@ u32 SlippiGameFileLoader::LoadFile(std::string file_name, std::string& data)
|
||||||
// If the file was a diff file and the game is running, load the main file from ISO and apply
|
// If the file was a diff file and the game is running, load the main file from ISO and apply
|
||||||
// patch
|
// patch
|
||||||
if (game_file_path.substr(game_file_path.length() - 5) == ".diff" &&
|
if (game_file_path.substr(game_file_path.length() - 5) == ".diff" &&
|
||||||
Core::GetState() == Core::State::Running)
|
Core::GetState(system) == Core::State::Running)
|
||||||
{
|
{
|
||||||
std::vector<u8> buf;
|
std::vector<u8> buf;
|
||||||
INFO_LOG_FMT(SLIPPI, "Will process diff");
|
INFO_LOG_FMT(SLIPPI, "Will process diff");
|
||||||
|
|
|
@ -5,11 +5,12 @@
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
|
#include "Core/System.h"
|
||||||
|
|
||||||
class SlippiGameFileLoader
|
class SlippiGameFileLoader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
u32 LoadFile(std::string file_name, std::string& contents);
|
u32 LoadFile(Core::System& system, std::string file_name, std::string& contents);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::unordered_map<std::string, std::string> file_cache;
|
std::unordered_map<std::string, std::string> file_cache;
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "Core/HW/EXI/EXI_DeviceSlippi.h"
|
#include "Core/HW/EXI/EXI_DeviceSlippi.h"
|
||||||
#include "Core/NetPlayClient.h"
|
#include "Core/NetPlayClient.h"
|
||||||
#include "Core/State.h"
|
#include "Core/State.h"
|
||||||
|
#include "Core/System.h"
|
||||||
#include "SlippiPlayback.h"
|
#include "SlippiPlayback.h"
|
||||||
|
|
||||||
#define FRAME_INTERVAL 900
|
#define FRAME_INTERVAL 900
|
||||||
|
@ -124,14 +125,14 @@ void SlippiPlaybackStatus::resetPlayback()
|
||||||
in_slippi_playback = false;
|
in_slippi_playback = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlippiPlaybackStatus::processInitialState()
|
void SlippiPlaybackStatus::processInitialState(Core::System& system)
|
||||||
{
|
{
|
||||||
INFO_LOG_FMT(SLIPPI, "saving initial_state");
|
INFO_LOG_FMT(SLIPPI, "saving initial_state");
|
||||||
State::SaveToBuffer(initial_state);
|
State::SaveToBuffer(system, initial_state);
|
||||||
// The initial save to curr_state causes a stutter of about 5-10 frames
|
// The initial save to curr_state causes a stutter of about 5-10 frames
|
||||||
// Doing it here to get it out of the way and prevent stutters later
|
// Doing it here to get it out of the way and prevent stutters later
|
||||||
// Subsequent calls to SaveToBuffer for curr_state take ~1 frame
|
// Subsequent calls to SaveToBuffer for curr_state take ~1 frame
|
||||||
State::SaveToBuffer(curr_state);
|
State::SaveToBuffer(system, curr_state);
|
||||||
if (Config::Get(Config::SLIPPI_ENABLE_SEEK))
|
if (Config::Get(Config::SLIPPI_ENABLE_SEEK))
|
||||||
{
|
{
|
||||||
Config::SetCurrent(Config::MAIN_SHOW_CURSOR, Config::ShowCursor::Constantly);
|
Config::SetCurrent(Config::MAIN_SHOW_CURSOR, Config::ShowCursor::Constantly);
|
||||||
|
@ -140,6 +141,7 @@ void SlippiPlaybackStatus::processInitialState()
|
||||||
|
|
||||||
void SlippiPlaybackStatus::SavestateThread()
|
void SlippiPlaybackStatus::SavestateThread()
|
||||||
{
|
{
|
||||||
|
Core::System& system = Core::System::GetInstance();
|
||||||
Common::SetCurrentThreadName("Savestate thread");
|
Common::SetCurrentThreadName("Savestate thread");
|
||||||
std::unique_lock<std::mutex> interval_lock(mtx);
|
std::unique_lock<std::mutex> interval_lock(mtx);
|
||||||
|
|
||||||
|
@ -165,14 +167,14 @@ void SlippiPlaybackStatus::SavestateThread()
|
||||||
|
|
||||||
if (!in_slippi_playback && is_start_frame)
|
if (!in_slippi_playback && is_start_frame)
|
||||||
{
|
{
|
||||||
processInitialState();
|
processInitialState(system);
|
||||||
in_slippi_playback = true;
|
in_slippi_playback = true;
|
||||||
}
|
}
|
||||||
else if (Config::Get(Config::SLIPPI_ENABLE_SEEK) && !has_state_been_processed &&
|
else if (Config::Get(Config::SLIPPI_ENABLE_SEEK) && !has_state_been_processed &&
|
||||||
!is_start_frame)
|
!is_start_frame)
|
||||||
{
|
{
|
||||||
INFO_LOG_FMT(SLIPPI, "saving diff at frame: {}", fixed_frame_num);
|
INFO_LOG_FMT(SLIPPI, "saving diff at frame: {}", fixed_frame_num);
|
||||||
State::SaveToBuffer(curr_state);
|
State::SaveToBuffer(system, curr_state);
|
||||||
|
|
||||||
future_diffs[fixed_frame_num] = std::async(processDiff, initial_state, curr_state);
|
future_diffs[fixed_frame_num] = std::async(processDiff, initial_state, curr_state);
|
||||||
}
|
}
|
||||||
|
@ -182,7 +184,7 @@ void SlippiPlaybackStatus::SavestateThread()
|
||||||
INFO_LOG_FMT(SLIPPI, "Exiting savestate thread");
|
INFO_LOG_FMT(SLIPPI, "Exiting savestate thread");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlippiPlaybackStatus::seekToFrame()
|
void SlippiPlaybackStatus::seekToFrame(Core::System& system)
|
||||||
{
|
{
|
||||||
if (seek_mtx.try_lock())
|
if (seek_mtx.try_lock())
|
||||||
{
|
{
|
||||||
|
@ -199,9 +201,9 @@ void SlippiPlaybackStatus::seekToFrame()
|
||||||
if (replay_comm_settings.mode == "queue")
|
if (replay_comm_settings.mode == "queue")
|
||||||
updateWatchSettingsStartEnd();
|
updateWatchSettingsStartEnd();
|
||||||
|
|
||||||
auto prev_state = Core::GetState();
|
auto prev_state = Core::GetState(system);
|
||||||
if (prev_state != Core::State::Paused)
|
if (prev_state != Core::State::Paused)
|
||||||
Core::SetState(Core::State::Paused);
|
Core::SetState(system, Core::State::Paused);
|
||||||
|
|
||||||
s32 closest_state_frame =
|
s32 closest_state_frame =
|
||||||
target_frame_num - emod(target_frame_num - Slippi::PLAYBACK_FIRST_SAVE, FRAME_INTERVAL);
|
target_frame_num - emod(target_frame_num - Slippi::PLAYBACK_FIRST_SAVE, FRAME_INTERVAL);
|
||||||
|
@ -212,14 +214,14 @@ void SlippiPlaybackStatus::seekToFrame()
|
||||||
{
|
{
|
||||||
if (closest_state_frame <= Slippi::PLAYBACK_FIRST_SAVE)
|
if (closest_state_frame <= Slippi::PLAYBACK_FIRST_SAVE)
|
||||||
{
|
{
|
||||||
State::LoadFromBuffer(initial_state);
|
State::LoadFromBuffer(system, initial_state);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If this diff exists, load it
|
// If this diff exists, load it
|
||||||
if (future_diffs.count(closest_state_frame) > 0)
|
if (future_diffs.count(closest_state_frame) > 0)
|
||||||
{
|
{
|
||||||
loadState(closest_state_frame);
|
loadState(system, closest_state_frame);
|
||||||
}
|
}
|
||||||
else if (target_frame_num < current_playback_frame)
|
else if (target_frame_num < current_playback_frame)
|
||||||
{
|
{
|
||||||
|
@ -227,7 +229,7 @@ void SlippiPlaybackStatus::seekToFrame()
|
||||||
while (closest_actual_state_frame > Slippi::PLAYBACK_FIRST_SAVE &&
|
while (closest_actual_state_frame > Slippi::PLAYBACK_FIRST_SAVE &&
|
||||||
future_diffs.count(closest_actual_state_frame) == 0)
|
future_diffs.count(closest_actual_state_frame) == 0)
|
||||||
closest_actual_state_frame -= FRAME_INTERVAL;
|
closest_actual_state_frame -= FRAME_INTERVAL;
|
||||||
loadState(closest_actual_state_frame);
|
loadState(system, closest_actual_state_frame);
|
||||||
}
|
}
|
||||||
else if (target_frame_num > current_playback_frame)
|
else if (target_frame_num > current_playback_frame)
|
||||||
{
|
{
|
||||||
|
@ -239,7 +241,7 @@ void SlippiPlaybackStatus::seekToFrame()
|
||||||
// only load a savestate if we find one past our current frame since we are seeking
|
// only load a savestate if we find one past our current frame since we are seeking
|
||||||
// forwards
|
// forwards
|
||||||
if (closest_actual_state_frame > current_playback_frame)
|
if (closest_actual_state_frame > current_playback_frame)
|
||||||
loadState(closest_actual_state_frame);
|
loadState(system, closest_actual_state_frame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -248,9 +250,9 @@ void SlippiPlaybackStatus::seekToFrame()
|
||||||
if (target_frame_num != closest_state_frame && target_frame_num != last_frame)
|
if (target_frame_num != closest_state_frame && target_frame_num != last_frame)
|
||||||
{
|
{
|
||||||
setHardFFW(true);
|
setHardFFW(true);
|
||||||
Core::SetState(Core::State::Running);
|
Core::SetState(system, Core::State::Running);
|
||||||
cv_waiting_for_target_frame.wait(ffw_lock);
|
cv_waiting_for_target_frame.wait(ffw_lock);
|
||||||
Core::SetState(Core::State::Paused);
|
Core::SetState(system, Core::State::Paused);
|
||||||
setHardFFW(false);
|
setHardFFW(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,7 +260,7 @@ void SlippiPlaybackStatus::seekToFrame()
|
||||||
// be performed
|
// be performed
|
||||||
g_playback_status->current_playback_frame = target_frame_num;
|
g_playback_status->current_playback_frame = target_frame_num;
|
||||||
target_frame_num = INT_MAX;
|
target_frame_num = INT_MAX;
|
||||||
Core::SetState(prev_state);
|
Core::SetState(system, prev_state);
|
||||||
seek_mtx.unlock();
|
seek_mtx.unlock();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -284,17 +286,17 @@ void SlippiPlaybackStatus::setHardFFW(bool enable)
|
||||||
is_hard_FFW = enable;
|
is_hard_FFW = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlippiPlaybackStatus::loadState(s32 closest_state_frame)
|
void SlippiPlaybackStatus::loadState(Core::System& system, s32 closest_state_frame)
|
||||||
{
|
{
|
||||||
if (closest_state_frame == Slippi::PLAYBACK_FIRST_SAVE)
|
if (closest_state_frame == Slippi::PLAYBACK_FIRST_SAVE)
|
||||||
State::LoadFromBuffer(initial_state);
|
State::LoadFromBuffer(system, initial_state);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string state_string;
|
std::string state_string;
|
||||||
decoder.Decode((char*)initial_state.data(), initial_state.size(),
|
decoder.Decode((char*)initial_state.data(), initial_state.size(),
|
||||||
future_diffs[closest_state_frame].get(), &state_string);
|
future_diffs[closest_state_frame].get(), &state_string);
|
||||||
std::vector<u8> state_to_load(state_string.begin(), state_string.end());
|
std::vector<u8> state_to_load(state_string.begin(), state_string.end());
|
||||||
State::LoadFromBuffer(state_to_load);
|
State::LoadFromBuffer(system, state_to_load);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,19 +34,19 @@ public:
|
||||||
|
|
||||||
std::thread m_savestate_thread;
|
std::thread m_savestate_thread;
|
||||||
|
|
||||||
void startThreads(void);
|
void startThreads();
|
||||||
void resetPlayback(void);
|
void resetPlayback(void);
|
||||||
bool shouldFFWFrame(s32 frame_idx) const;
|
bool shouldFFWFrame(s32 frame_idx) const;
|
||||||
void prepareSlippiPlayback(s32& frame_idx);
|
void prepareSlippiPlayback(s32& frame_idx);
|
||||||
void setHardFFW(bool enable);
|
void setHardFFW(bool enable);
|
||||||
std::unordered_map<u32, bool> getDenylist();
|
std::unordered_map<u32, bool> getDenylist();
|
||||||
std::vector<u8> getLegacyCodelist();
|
std::vector<u8> getLegacyCodelist();
|
||||||
void seekToFrame();
|
void seekToFrame(Core::System& system);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SavestateThread(void);
|
void SavestateThread();
|
||||||
void loadState(s32 closest_state_frame);
|
void loadState(Core::System& system, s32 closest_state_frame);
|
||||||
void processInitialState();
|
void processInitialState(Core::System& system);
|
||||||
void updateWatchSettingsStartEnd();
|
void updateWatchSettingsStartEnd();
|
||||||
void generateDenylist();
|
void generateDenylist();
|
||||||
void generateLegacyCodelist();
|
void generateLegacyCodelist();
|
||||||
|
|
|
@ -57,7 +57,7 @@ void GeneralWidget::CreateWidgets()
|
||||||
m_video_layout = new QGridLayout();
|
m_video_layout = new QGridLayout();
|
||||||
|
|
||||||
m_backend_combo = new ToolTipComboBox();
|
m_backend_combo = new ToolTipComboBox();
|
||||||
m_aspect_combo = new ConfigChoice({tr("Auto"), tr("Force 16:9"), tr("Force 4:3"), tr("Force 73:60 (Melee)")
|
m_aspect_combo = new ConfigChoice({tr("Auto"), tr("Force 16:9"), tr("Force 4:3"), tr("Force 73:60 (Melee)"),
|
||||||
tr("Stretch to Window"), tr("Custom"), tr("Custom (Stretch)")},
|
tr("Stretch to Window"), tr("Custom"), tr("Custom (Stretch)")},
|
||||||
Config::GFX_ASPECT_RATIO);
|
Config::GFX_ASPECT_RATIO);
|
||||||
m_custom_aspect_label = new QLabel(tr("Custom Aspect Ratio:"));
|
m_custom_aspect_label = new QLabel(tr("Custom Aspect Ratio:"));
|
||||||
|
|
|
@ -611,5 +611,5 @@ void RenderWidget::Exit()
|
||||||
|
|
||||||
void RenderWidget::PlaybackSeek()
|
void RenderWidget::PlaybackSeek()
|
||||||
{
|
{
|
||||||
g_playback_status->seekToFrame();
|
g_playback_status->seekToFrame(Core::System::GetInstance());
|
||||||
}
|
}
|
||||||
|
|
|
@ -411,7 +411,7 @@ void AudioPane::OnVolumeChanged(int volume)
|
||||||
m_volume_indicator->setText(tr("%1%").arg(volume));
|
m_volume_indicator->setText(tr("%1%").arg(volume));
|
||||||
|
|
||||||
#ifndef IS_PLAYBACK
|
#ifndef IS_PLAYBACK
|
||||||
if (Core::GetState() == Core::State::Running)
|
if (Core::GetState(Core::System::GetInstance()) == Core::State::Running)
|
||||||
{
|
{
|
||||||
auto& system = Core::System::GetInstance();
|
auto& system = Core::System::GetInstance();
|
||||||
auto& exi_manager = system.GetExpansionInterface();
|
auto& exi_manager = system.GetExpansionInterface();
|
||||||
|
|
|
@ -285,7 +285,7 @@ void SlippiPane::ToggleJukebox(bool checked)
|
||||||
Config::SetBase(Config::SLIPPI_ENABLE_JUKEBOX, checked);
|
Config::SetBase(Config::SLIPPI_ENABLE_JUKEBOX, checked);
|
||||||
m_music_volume_slider->setDisabled(!checked);
|
m_music_volume_slider->setDisabled(!checked);
|
||||||
|
|
||||||
if (Core::GetState() == Core::State::Running)
|
if (Core::GetState(Core::System::GetInstance()) == Core::State::Running)
|
||||||
{
|
{
|
||||||
auto& system = Core::System::GetInstance();
|
auto& system = Core::System::GetInstance();
|
||||||
auto& exi_manager = system.GetExpansionInterface();
|
auto& exi_manager = system.GetExpansionInterface();
|
||||||
|
@ -301,7 +301,7 @@ void SlippiPane::OnMusicVolumeUpdate(int volume)
|
||||||
{
|
{
|
||||||
Config::SetBase(Config::SLIPPI_JUKEBOX_VOLUME, volume);
|
Config::SetBase(Config::SLIPPI_JUKEBOX_VOLUME, volume);
|
||||||
m_music_volume_percent->setText(tr(" %1%").arg(volume));
|
m_music_volume_percent->setText(tr(" %1%").arg(volume));
|
||||||
if (Core::GetState() == Core::State::Running)
|
if (Core::GetState(Core::System::GetInstance()) == Core::State::Running)
|
||||||
{
|
{
|
||||||
auto& system = Core::System::GetInstance();
|
auto& system = Core::System::GetInstance();
|
||||||
auto& exi_manager = system.GetExpansionInterface();
|
auto& exi_manager = system.GetExpansionInterface();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue