Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core/Movie: Refactor to class, move to System. #830

Merged
merged 3 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Source/Core/Core/BootManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,13 @@ bool BootCore(std::unique_ptr<BootParameters> boot, const WindowSystemInfo& wsi)
return false;

// Movie settings
if (Movie::IsPlayingInput() && Movie::IsConfigSaved())
auto& system = Core::System::GetInstance();
auto& movie = system.GetMovie();
if (movie.IsPlayingInput() && movie.IsConfigSaved())
{
for (ExpansionInterface::Slot slot : ExpansionInterface::MEMCARD_SLOTS)
{
if (Movie::IsUsingMemcard(slot) && Movie::IsStartingFromClearSave() && !StartUp.bWii)
if (movie.IsUsingMemcard(slot) && movie.IsStartingFromClearSave() && !StartUp.bWii)
{
const auto raw_path =
File::GetUserPath(D_GCUSER_IDX) +
Expand Down Expand Up @@ -142,7 +144,6 @@ bool BootCore(std::unique_ptr<BootParameters> boot, const WindowSystemInfo& wsi)
if (!boot->riivolution_patches.empty())
Config::SetCurrent(Config::MAIN_FAST_DISC_SPEED, true);

auto& system = Core::System::GetInstance();
system.Initialize();

Core::UpdateWantDeterminism(/*initial*/ true);
Expand Down
8 changes: 4 additions & 4 deletions Source/Core/Core/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,8 @@ static void EmuThread(Core::System& system, std::unique_ptr<BootParameters> boot
system.GetCustomAssetLoader().Init();
Common::ScopeGuard asset_loader_guard([&system] { system.GetCustomAssetLoader().Shutdown(); });

Movie::Init(*boot);
Common::ScopeGuard movie_guard{&Movie::Shutdown};
system.GetMovie().Init(*boot);
Common::ScopeGuard movie_guard([&system] { system.GetMovie().Shutdown(); });

AudioCommon::InitSoundStream(system);
Common::ScopeGuard audio_guard([&system] { AudioCommon::ShutdownSoundStream(system); });
Expand Down Expand Up @@ -1019,7 +1019,8 @@ void UpdateWantDeterminism(bool initial)
// For now, this value is not itself configurable. Instead, individual
// settings that depend on it, such as GPU determinism mode. should have
// override options for testing,
bool new_want_determinism = Movie::IsMovieActive() || NetPlay::IsNetPlayRunning();
auto& system = Core::System::GetInstance();
bool new_want_determinism = system.GetMovie().IsMovieActive() || NetPlay::IsNetPlayRunning();
if (new_want_determinism != s_wants_determinism || initial)
{
NOTICE_LOG_FMT(COMMON, "Want determinism <- {}", new_want_determinism ? "true" : "false");
Expand All @@ -1030,7 +1031,6 @@ void UpdateWantDeterminism(bool initial)
if (ios)
ios->UpdateWantDeterminism(new_want_determinism);

auto& system = Core::System::GetInstance();
system.GetFifo().UpdateWantDeterminism(new_want_determinism);

// We need to clear the cache because some parts of the JIT depend on want_determinism,
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Core/DolphinAnalytics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "Core/HW/GCPad.h"
#include "Core/Movie.h"
#include "Core/NetPlayProto.h"
#include "Core/System.h"
#include "InputCommon/GCAdapter.h"
#include "InputCommon/InputConfig.h"
#include "VideoCommon/VideoBackendBase.h"
Expand Down Expand Up @@ -417,7 +418,7 @@ void DolphinAnalytics::MakePerGameBuilder()

// NetPlay / recording.
builder.AddData("netplay", NetPlay::IsNetPlayRunning());
builder.AddData("movie", Movie::IsMovieActive());
builder.AddData("movie", Core::System::GetInstance().GetMovie().IsMovieActive());

// Controller information
// We grab enough to tell what percentage of our users are playing with keyboard/mouse, some kind
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/HW/DVD/DVDInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ void DVDInterface::ChangeDisc(const std::string& new_path)
m_disc_path_to_insert = new_path;
m_system.GetCoreTiming().ScheduleEvent(m_system.GetSystemTimers().GetTicksPerSecond(),
m_insert_disc);
Movie::SignalDiscChange(new_path);
m_system.GetMovie().SignalDiscChange(new_path);

for (size_t i = 0; i < m_auto_disc_change_paths.size(); ++i)
{
Expand Down Expand Up @@ -1087,7 +1087,7 @@ void DVDInterface::ExecuteCommand(ReplyType reply_type)

const bool force_eject = eject && !kill;

if (Config::Get(Config::MAIN_AUTO_DISC_CHANGE) && !Movie::IsPlayingInput() &&
if (Config::Get(Config::MAIN_AUTO_DISC_CHANGE) && !m_system.GetMovie().IsPlayingInput() &&
m_system.GetDVDThread().IsInsertedDiscRunning() && !m_auto_disc_change_paths.empty())
{
m_system.GetCoreTiming().ScheduleEvent(
Expand Down
6 changes: 4 additions & 2 deletions Source/Core/Core/HW/EXI/EXI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ ExpansionInterfaceManager::~ExpansionInterfaceManager() = default;
void ExpansionInterfaceManager::AddMemoryCard(Slot slot)
{
EXIDeviceType memorycard_device;
if (Movie::IsPlayingInput() && Movie::IsConfigSaved())

auto& movie = m_system.GetMovie();
if (movie.IsPlayingInput() && movie.IsConfigSaved())
{
if (Movie::IsUsingMemcard(slot))
if (movie.IsUsingMemcard(slot))
{
memorycard_device = Config::Get(Config::GetInfoForEXIDevice(slot));
if (memorycard_device != EXIDeviceType::MemoryCardFolder &&
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/EXI/EXI_Channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ void CEXIChannel::DoState(PointerWrap& p)
}

if (type == EXIDeviceType::MemoryCardFolder && old_header_data != m_memcard_header_data &&
!Movie::IsMovieActive())
!m_system.GetMovie().IsMovieActive())
{
// We have loaded a savestate that has a GCI folder memcard that is different to the virtual
// card that is currently active. In order to prevent the game from recognizing this card as a
Expand Down
5 changes: 3 additions & 2 deletions Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,10 @@ u32 CEXIIPL::GetEmulatedTime(Core::System& system, u32 epoch)
{
u64 ltime = 0;

if (Movie::IsMovieActive())
auto& movie = system.GetMovie();
if (movie.IsMovieActive())
{
ltime = Movie::GetRecordingStartTime();
ltime = movie.GetRecordingStartTime();

// let's keep time moving forward, regardless of what it starts at
ltime += system.GetCoreTiming().GetTicks() / system.GetSystemTimers().GetTicksPerSecond();
Expand Down
18 changes: 10 additions & 8 deletions Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,17 @@ CEXIMemoryCard::CEXIMemoryCard(Core::System& system, const Slot slot, bool gci_f
}

std::pair<std::string /* path */, bool /* migrate */>
CEXIMemoryCard::GetGCIFolderPath(Slot card_slot, AllowMovieFolder allow_movie_folder)
CEXIMemoryCard::GetGCIFolderPath(Slot card_slot, AllowMovieFolder allow_movie_folder,
Movie::MovieManager& movie)
{
std::string path_override = Config::Get(Config::GetInfoForGCIPathOverride(card_slot));

if (!path_override.empty())
return {std::move(path_override), false};

const bool use_movie_folder = allow_movie_folder == AllowMovieFolder::Yes &&
Movie::IsPlayingInput() && Movie::IsConfigSaved() &&
Movie::IsUsingMemcard(card_slot) &&
Movie::IsStartingFromClearSave();
movie.IsPlayingInput() && movie.IsConfigSaved() &&
movie.IsUsingMemcard(card_slot) && movie.IsStartingFromClearSave();

const DiscIO::Region region = Config::ToGameCubeRegion(SConfig::GetInstance().m_region);
if (use_movie_folder)
Expand All @@ -182,7 +182,8 @@ void CEXIMemoryCard::SetupGciFolder(const Memcard::HeaderData& header_data)
current_game_id = Common::swap32(reinterpret_cast<const u8*>(game_id.c_str()));
}

const auto [dir_path, migrate] = GetGCIFolderPath(m_card_slot, AllowMovieFolder::Yes);
const auto [dir_path, migrate] =
GetGCIFolderPath(m_card_slot, AllowMovieFolder::Yes, m_system.GetMovie());

const File::FileInfo file_info(dir_path);
if (!file_info.Exists())
Expand Down Expand Up @@ -219,8 +220,9 @@ void CEXIMemoryCard::SetupGciFolder(const Memcard::HeaderData& header_data)
void CEXIMemoryCard::SetupRawMemcard(u16 size_mb)
{
std::string filename;
if (Movie::IsPlayingInput() && Movie::IsConfigSaved() && Movie::IsUsingMemcard(m_card_slot) &&
Movie::IsStartingFromClearSave())
auto& movie = m_system.GetMovie();
if (movie.IsPlayingInput() && movie.IsConfigSaved() && movie.IsUsingMemcard(m_card_slot) &&
movie.IsStartingFromClearSave())
{
filename = File::GetUserPath(D_GCUSER_IDX) +
fmt::format("Movie{}.raw", s_card_short_names[m_card_slot]);
Expand Down Expand Up @@ -501,7 +503,7 @@ void CEXIMemoryCard::DoState(PointerWrap& p)
// otherwise, we'll assume the user wants to keep their memcards and saves separate,
// unless we're loading (in which case we let the savestate contents decide, in order to stay
// aligned with them).
bool storeContents = (Movie::IsMovieActive());
bool storeContents = m_system.GetMovie().IsMovieActive();
p.Do(storeContents);

if (storeContents)
Expand Down
6 changes: 5 additions & 1 deletion Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ namespace Memcard
{
struct HeaderData;
}
namespace Movie
{
class MovieManager;
}

namespace ExpansionInterface
{
Expand Down Expand Up @@ -58,7 +62,7 @@ class CEXIMemoryCard : public IEXIDevice
static void Shutdown();

static std::pair<std::string /* path */, bool /* migrate */>
GetGCIFolderPath(Slot card_slot, AllowMovieFolder allow_movie_folder);
GetGCIFolderPath(Slot card_slot, AllowMovieFolder allow_movie_folder, Movie::MovieManager& movie);

private:
void SetupGciFolder(const Memcard::HeaderData& header_data);
Expand Down
9 changes: 5 additions & 4 deletions Source/Core/Core/HW/SI/SI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,19 +265,20 @@ void SerialInterfaceManager::Init()
m_channel[i].in_lo.hex = 0;
m_channel[i].has_recent_device_change = false;

if (Movie::IsMovieActive())
auto& movie = m_system.GetMovie();
if (movie.IsMovieActive())
{
m_desired_device_types[i] = SIDEVICE_NONE;

if (Movie::IsUsingGBA(i))
if (movie.IsUsingGBA(i))
{
m_desired_device_types[i] = SIDEVICE_GC_GBA_EMULATED;
}
else if (Movie::IsUsingPad(i))
else if (movie.IsUsingPad(i))
{
SIDevices current = Config::Get(Config::GetInfoForSIDevice(i));
// GC pad-compatible devices can be used for both playing and recording
if (Movie::IsUsingBongo(i))
if (movie.IsUsingBongo(i))
m_desired_device_types[i] = SIDEVICE_GC_TARUKONGA;
else if (SIDevice_IsGCController(current))
m_desired_device_types[i] = current;
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Core/HW/SI/SI_DeviceGBAEmu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ bool CSIDevice_GBAEmu::GetData(u32& hi, u32& low)
GCPadStatus pad_status{};
if (!NetPlay::IsNetPlayRunning())
pad_status = Pad::GetGBAStatus(m_device_number);
SerialInterface::CSIDevice_GCController::HandleMoviePadStatus(m_device_number, &pad_status);
SerialInterface::CSIDevice_GCController::HandleMoviePadStatus(m_system.GetMovie(),
m_device_number, &pad_status);

static constexpr std::array<PadButton, 10> buttons_map = {
PadButton::PAD_BUTTON_A, // A
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Core/HW/SI/SI_DeviceGCAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Core/Core.h"
#include "Core/HW/GCPad.h"
#include "Core/NetPlayProto.h"
#include "Core/System.h"
#include "InputCommon/GCAdapter.h"

namespace SerialInterface
Expand Down Expand Up @@ -38,7 +39,7 @@ GCPadStatus CSIDevice_GCAdapter::GetPadStatus()
pad_status = GCAdapter::Input(m_device_number);
}

HandleMoviePadStatus(m_device_number, &pad_status);
HandleMoviePadStatus(m_system.GetMovie(), m_device_number, &pad_status);

// Our GCAdapter code sets PAD_GET_ORIGIN when a new device has been connected.
// Watch for this to calibrate real controllers on connection.
Expand Down
25 changes: 13 additions & 12 deletions Source/Core/Core/HW/SI/SI_DeviceGCController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,27 +120,28 @@ int CSIDevice_GCController::RunBuffer(u8* buffer, int request_length)
return 0;
}

void CSIDevice_GCController::HandleMoviePadStatus(int device_number, GCPadStatus* pad_status)
void CSIDevice_GCController::HandleMoviePadStatus(Movie::MovieManager& movie, int device_number,
GCPadStatus* pad_status)
{
Movie::CallGCInputManip(pad_status, device_number);

Movie::SetPolledDevice();
movie.CallGCInputManip(pad_status, device_number);
movie.SetPolledDevice();
if (NetPlay_GetInput(device_number, pad_status))
{
}
else if (Movie::IsPlayingInput())
else if (movie.IsPlayingInput())
{
Movie::PlayController(pad_status, device_number);
Movie::InputUpdate();
movie.PlayController(pad_status, device_number);
movie.InputUpdate();
}
else if (Movie::IsRecordingInput())
else if (movie.IsRecordingInput())
{
Movie::RecordInput(pad_status, device_number);
Movie::InputUpdate();
movie.RecordInput(pad_status, device_number);
movie.InputUpdate();
}
else
{
Movie::CheckPadStatus(pad_status, device_number);
movie.CheckPadStatus(pad_status, device_number);
}
}

Expand All @@ -155,7 +156,7 @@ GCPadStatus CSIDevice_GCController::GetPadStatus()
pad_status = Pad::GetStatus(m_device_number);
}

HandleMoviePadStatus(m_device_number, &pad_status);
HandleMoviePadStatus(m_system.GetMovie(), m_device_number, &pad_status);

// Our GCAdapter code sets PAD_GET_ORIGIN when a new device has been connected.
// Watch for this to calibrate real controllers on connection.
Expand Down
8 changes: 7 additions & 1 deletion Source/Core/Core/HW/SI/SI_DeviceGCController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
#include "Core/HW/SI/SI_Device.h"
#include "InputCommon/GCPadStatus.h"

namespace Movie
{
class MovieManager;
}

namespace SerialInterface
{
class CSIDevice_GCController : public ISIDevice
Expand Down Expand Up @@ -78,7 +83,8 @@ class CSIDevice_GCController : public ISIDevice
// Direct rumble to the right GC Controller
static void Rumble(int pad_num, ControlState strength, SIDevices device);

static void HandleMoviePadStatus(int device_number, GCPadStatus* pad_status);
static void HandleMoviePadStatus(Movie::MovieManager& movie, int device_number,
GCPadStatus* pad_status);

protected:
void SetOrigin(const GCPadStatus& pad_status);
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/VideoInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ void VideoInterfaceManager::Update(u64 ticks)
// in case frame counter display is enabled

if (m_half_line_count == 0 || m_half_line_count == GetHalfLinesPerEvenField())
Movie::FrameUpdate();
m_system.GetMovie().FrameUpdate();

// If this half-line is at some boundary of the "active video lines" in either field, we either
// need to (a) send a request to the GPU thread to actually render the XFB, or (b) increment
Expand Down
6 changes: 4 additions & 2 deletions Source/Core/Core/HW/Wiimote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "Core/IOS/USB/Bluetooth/WiimoteDevice.h"
#include "Core/Movie.h"
#include "Core/NetPlayClient.h"
#include "Core/System.h"
#include "Core/WiiUtils.h"

#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
Expand Down Expand Up @@ -192,8 +193,9 @@ void Initialize(InitializeMode init_mode)
WiimoteReal::Initialize(init_mode);

// Reload Wiimotes with our settings
if (Movie::IsMovieActive())
Movie::ChangeWiiPads();
auto& movie = Core::System::GetInstance().GetMovie();
if (movie.IsMovieActive())
movie.ChangeWiiPads();
}

void ResetAllWiimotes()
Expand Down
16 changes: 8 additions & 8 deletions Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "Core/Core.h"
#include "Core/HW/Wiimote.h"
#include "Core/Movie.h"
#include "Core/System.h"

#include "Core/HW/WiimoteCommon/WiimoteConstants.h"
#include "Core/HW/WiimoteCommon/WiimoteHid.h"
Expand Down Expand Up @@ -550,7 +551,8 @@ void Wiimote::Update(const WiimoteEmu::DesiredWiimoteState& target_state)

void Wiimote::SendDataReport(const DesiredWiimoteState& target_state)
{
Movie::SetPolledDevice();
auto& movie = Core::System::GetInstance().GetMovie();
movie.SetPolledDevice();

if (InputReportID::ReportDisabled == m_reporting_mode)
{
Expand All @@ -567,9 +569,8 @@ void Wiimote::SendDataReport(const DesiredWiimoteState& target_state)

DataReportBuilder rpt_builder(m_reporting_mode);

if (Movie::IsPlayingInput() &&
Movie::PlayWiimote(m_bt_device_index, rpt_builder, m_active_extension,
GetExtensionEncryptionKey()))
if (movie.IsPlayingInput() && movie.PlayWiimote(m_bt_device_index, rpt_builder,
m_active_extension, GetExtensionEncryptionKey()))
{
// Update buttons in status struct from movie:
rpt_builder.GetCoreData(&m_status.buttons);
Expand Down Expand Up @@ -636,13 +637,12 @@ void Wiimote::SendDataReport(const DesiredWiimoteState& target_state)
std::fill_n(ext_data, ext_size, u8(0xff));
}
}

Movie::CallWiiInputManip(rpt_builder, m_bt_device_index, m_active_extension,
movie.CallWiiInputManip(rpt_builder, m_bt_device_index, m_active_extension,
GetExtensionEncryptionKey());
}

Movie::CheckWiimoteStatus(m_bt_device_index, rpt_builder, m_active_extension,
GetExtensionEncryptionKey());
movie.CheckWiimoteStatus(m_bt_device_index, rpt_builder, m_active_extension,
GetExtensionEncryptionKey());

// Send the report:
InterruptDataInputCallback(rpt_builder.GetDataPtr(), rpt_builder.GetDataSize());
Expand Down
Loading