core: De-globalize movie (#6659)
This commit is contained in:
parent
a955f02771
commit
f8b8b6e53c
51 changed files with 182 additions and 104 deletions
|
@ -2,8 +2,6 @@
|
|||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <exception>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
#include <boost/serialization/array.hpp>
|
||||
|
@ -16,6 +14,8 @@
|
|||
#include "core/arm/arm_interface.h"
|
||||
#include "core/arm/exclusive_monitor.h"
|
||||
#include "core/hle/service/cam/cam.h"
|
||||
#include "core/hle/service/hid/hid.h"
|
||||
#include "core/hle/service/ir/ir_user.h"
|
||||
#if CITRA_ARCH(x86_64) || CITRA_ARCH(arm64)
|
||||
#include "core/arm/dynarmic/arm_dynarmic.h"
|
||||
#endif
|
||||
|
@ -35,9 +35,7 @@
|
|||
#include "core/hle/service/cam/cam.h"
|
||||
#include "core/hle/service/fs/archive.h"
|
||||
#include "core/hle/service/gsp/gsp.h"
|
||||
#include "core/hle/service/hid/hid.h"
|
||||
#include "core/hle/service/ir/ir_rst.h"
|
||||
#include "core/hle/service/ir/ir_user.h"
|
||||
#include "core/hle/service/mic_u.h"
|
||||
#include "core/hle/service/plgldr/plgldr.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
@ -48,6 +46,7 @@
|
|||
#include "core/loader/loader.h"
|
||||
#include "core/movie.h"
|
||||
#include "core/rpc/server.h"
|
||||
#include "core/telemetry_session.h"
|
||||
#include "network/network.h"
|
||||
#include "video_core/custom_textures/custom_tex_manager.h"
|
||||
#include "video_core/renderer_base.h"
|
||||
|
@ -72,6 +71,8 @@ Core::Timing& Global() {
|
|||
return System::GetInstance().CoreTiming();
|
||||
}
|
||||
|
||||
System::System() : movie{*this} {}
|
||||
|
||||
System::~System() = default;
|
||||
|
||||
System::ResultStatus System::RunLoop(bool tight_loop) {
|
||||
|
@ -372,7 +373,8 @@ System::ResultStatus System::Init(Frontend::EmuWindow& emu_window,
|
|||
timing = std::make_unique<Timing>(num_cores, Settings::values.cpu_clock_percentage.GetValue());
|
||||
|
||||
kernel = std::make_unique<Kernel::KernelSystem>(
|
||||
*memory, *timing, [this] { PrepareReschedule(); }, memory_mode, num_cores, n3ds_hw_caps);
|
||||
*memory, *timing, [this] { PrepareReschedule(); }, memory_mode, num_cores, n3ds_hw_caps,
|
||||
movie.GetOverrideInitTime());
|
||||
|
||||
exclusive_monitor = MakeExclusiveMonitor(*memory, num_cores);
|
||||
cpu_cores.reserve(num_cores);
|
||||
|
@ -508,6 +510,14 @@ const VideoCore::CustomTexManager& System::CustomTexManager() const {
|
|||
return *custom_tex_manager;
|
||||
}
|
||||
|
||||
Core::Movie& System::Movie() {
|
||||
return movie;
|
||||
}
|
||||
|
||||
const Core::Movie& System::Movie() const {
|
||||
return movie;
|
||||
}
|
||||
|
||||
void System::RegisterMiiSelector(std::shared_ptr<Frontend::MiiSelector> mii_selector) {
|
||||
registered_mii_selector = std::move(mii_selector);
|
||||
}
|
||||
|
@ -702,7 +712,7 @@ void System::serialize(Archive& ar, const unsigned int file_version) {
|
|||
ar&* kernel.get();
|
||||
VideoCore::serialize(ar, file_version);
|
||||
if (file_version >= 1) {
|
||||
ar& Movie::GetInstance();
|
||||
ar& movie;
|
||||
}
|
||||
|
||||
// This needs to be set from somewhere - might as well be here!
|
||||
|
|
|
@ -10,18 +10,17 @@
|
|||
#include <string>
|
||||
#include <boost/serialization/version.hpp>
|
||||
#include "common/common_types.h"
|
||||
#include "core/frontend/applets/mii_selector.h"
|
||||
#include "core/frontend/applets/swkbd.h"
|
||||
#include "core/loader/loader.h"
|
||||
#include "core/memory.h"
|
||||
#include "core/arm/arm_interface.h"
|
||||
#include "core/movie.h"
|
||||
#include "core/perf_stats.h"
|
||||
#include "core/telemetry_session.h"
|
||||
|
||||
class ARM_Interface;
|
||||
|
||||
namespace Frontend {
|
||||
class EmuWindow;
|
||||
class ImageInterface;
|
||||
class MiiSelector;
|
||||
class SoftwareKeyboard;
|
||||
} // namespace Frontend
|
||||
|
||||
namespace Memory {
|
||||
|
@ -47,7 +46,9 @@ class ArchiveManager;
|
|||
|
||||
namespace Kernel {
|
||||
class KernelSystem;
|
||||
}
|
||||
struct New3dsHwCapabilities;
|
||||
enum class MemoryMode : u8;
|
||||
} // namespace Kernel
|
||||
|
||||
namespace Cheats {
|
||||
class CheatEngine;
|
||||
|
@ -62,8 +63,13 @@ class CustomTexManager;
|
|||
class RendererBase;
|
||||
} // namespace VideoCore
|
||||
|
||||
namespace Loader {
|
||||
class AppLoader;
|
||||
}
|
||||
|
||||
namespace Core {
|
||||
|
||||
class TelemetrySession;
|
||||
class ExclusiveMonitor;
|
||||
class Timing;
|
||||
|
||||
|
@ -95,6 +101,7 @@ public:
|
|||
ErrorUnknown ///< Any other error
|
||||
};
|
||||
|
||||
explicit System();
|
||||
~System();
|
||||
|
||||
/**
|
||||
|
@ -258,6 +265,12 @@ public:
|
|||
/// Gets a const reference to the custom texture cache system
|
||||
[[nodiscard]] const VideoCore::CustomTexManager& CustomTexManager() const;
|
||||
|
||||
/// Gets a reference to the movie recorder
|
||||
[[nodiscard]] Core::Movie& Movie();
|
||||
|
||||
/// Gets a const reference to the movie recorder
|
||||
[[nodiscard]] const Core::Movie& Movie() const;
|
||||
|
||||
/// Video Dumper interface
|
||||
|
||||
void RegisterVideoDumper(std::shared_ptr<VideoDumper::Backend> video_dumper);
|
||||
|
@ -373,6 +386,9 @@ private:
|
|||
std::shared_ptr<Frontend::MiiSelector> registered_mii_selector;
|
||||
std::shared_ptr<Frontend::SoftwareKeyboard> registered_swkbd;
|
||||
|
||||
/// Movie recorder
|
||||
Core::Movie movie;
|
||||
|
||||
/// Cheats manager
|
||||
std::unique_ptr<Cheats::CheatEngine> cheat_engine;
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
#include "common/common_types.h"
|
||||
#include "common/file_util.h"
|
||||
#include "common/swap.h"
|
||||
#include "core/core.h"
|
||||
#include "core/file_sys/romfs_reader.h"
|
||||
#include "core/loader/loader.h"
|
||||
|
||||
enum NCSDContentIndex { Main = 0, Manual = 1, DLP = 2, New3DSUpdate = 6, Update = 7 };
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include "common/archives.h"
|
||||
#include "common/assert.h"
|
||||
#include "common/common_types.h"
|
||||
#include "core/core.h"
|
||||
|
|
|
@ -25,13 +25,13 @@ namespace Kernel {
|
|||
KernelSystem::KernelSystem(Memory::MemorySystem& memory, Core::Timing& timing,
|
||||
std::function<void()> prepare_reschedule_callback,
|
||||
MemoryMode memory_mode, u32 num_cores,
|
||||
const New3dsHwCapabilities& n3ds_hw_caps)
|
||||
const New3dsHwCapabilities& n3ds_hw_caps, u64 override_init_time)
|
||||
: memory(memory), timing(timing),
|
||||
prepare_reschedule_callback(std::move(prepare_reschedule_callback)), memory_mode(memory_mode),
|
||||
n3ds_hw_caps(n3ds_hw_caps) {
|
||||
std::generate(memory_regions.begin(), memory_regions.end(),
|
||||
[] { return std::make_shared<MemoryRegionInfo>(); });
|
||||
MemoryInit(memory_mode, n3ds_hw_caps.memory_mode);
|
||||
MemoryInit(memory_mode, n3ds_hw_caps.memory_mode, override_init_time);
|
||||
|
||||
resource_limits = std::make_unique<ResourceLimitList>(*this);
|
||||
for (u32 core_id = 0; core_id < num_cores; ++core_id) {
|
||||
|
|
|
@ -134,7 +134,8 @@ class KernelSystem {
|
|||
public:
|
||||
explicit KernelSystem(Memory::MemorySystem& memory, Core::Timing& timing,
|
||||
std::function<void()> prepare_reschedule_callback, MemoryMode memory_mode,
|
||||
u32 num_cores, const New3dsHwCapabilities& n3ds_hw_caps);
|
||||
u32 num_cores, const New3dsHwCapabilities& n3ds_hw_caps,
|
||||
u64 override_init_time = 0);
|
||||
~KernelSystem();
|
||||
|
||||
using PortPair = std::pair<std::shared_ptr<ServerPort>, std::shared_ptr<ClientPort>>;
|
||||
|
@ -330,7 +331,7 @@ public:
|
|||
Core::Timing& timing;
|
||||
|
||||
private:
|
||||
void MemoryInit(MemoryMode memory_mode, New3dsMemoryMode n3ds_mode);
|
||||
void MemoryInit(MemoryMode memory_mode, New3dsMemoryMode n3ds_mode, u64 override_init_time);
|
||||
|
||||
std::function<void()> prepare_reschedule_callback;
|
||||
|
||||
|
|
|
@ -37,7 +37,8 @@ static const u32 memory_region_sizes[8][3] = {
|
|||
{0x0B200000, 0x02E00000, 0x02000000}, // 7
|
||||
};
|
||||
|
||||
void KernelSystem::MemoryInit(MemoryMode memory_mode, New3dsMemoryMode n3ds_mode) {
|
||||
void KernelSystem::MemoryInit(MemoryMode memory_mode, New3dsMemoryMode n3ds_mode,
|
||||
u64 override_init_time) {
|
||||
const bool is_new_3ds = Settings::values.is_new_3ds.GetValue();
|
||||
u32 mem_type_index = static_cast<u32>(memory_mode);
|
||||
u32 reported_mem_type = static_cast<u32>(memory_mode);
|
||||
|
@ -73,7 +74,7 @@ void KernelSystem::MemoryInit(MemoryMode memory_mode, New3dsMemoryMode n3ds_mode
|
|||
config_mem.sys_mem_alloc = memory_regions[1]->size;
|
||||
config_mem.base_mem_alloc = memory_regions[2]->size;
|
||||
|
||||
shared_page_handler = std::make_shared<SharedPage::Handler>(timing);
|
||||
shared_page_handler = std::make_shared<SharedPage::Handler>(timing, override_init_time);
|
||||
}
|
||||
|
||||
std::shared_ptr<MemoryRegionInfo> KernelSystem::GetMemoryRegion(MemoryRegion region) {
|
||||
|
|
|
@ -19,7 +19,8 @@ namespace boost::serialization {
|
|||
|
||||
template <class Archive>
|
||||
void load_construct_data(Archive& ar, SharedPage::Handler* t, const unsigned int) {
|
||||
::new (t) SharedPage::Handler(Core::System::GetInstance().CoreTiming());
|
||||
::new (t) SharedPage::Handler(Core::System::GetInstance().CoreTiming(),
|
||||
Core::System::GetInstance().Movie().GetOverrideInitTime());
|
||||
}
|
||||
template void load_construct_data<iarchive>(iarchive& ar, SharedPage::Handler* t,
|
||||
const unsigned int);
|
||||
|
@ -28,8 +29,7 @@ template void load_construct_data<iarchive>(iarchive& ar, SharedPage::Handler* t
|
|||
|
||||
namespace SharedPage {
|
||||
|
||||
static std::chrono::seconds GetInitTime() {
|
||||
const u64 override_init_time = Core::Movie::GetInstance().GetOverrideInitTime();
|
||||
static std::chrono::seconds GetInitTime(u64 override_init_time) {
|
||||
if (override_init_time != 0) {
|
||||
// Override the clock init time with the one in the movie
|
||||
return std::chrono::seconds(override_init_time);
|
||||
|
@ -62,7 +62,7 @@ static std::chrono::seconds GetInitTime() {
|
|||
}
|
||||
}
|
||||
|
||||
Handler::Handler(Core::Timing& timing) : timing(timing) {
|
||||
Handler::Handler(Core::Timing& timing, u64 override_init_time) : timing(timing) {
|
||||
std::memset(&shared_page, 0, sizeof(shared_page));
|
||||
|
||||
shared_page.running_hw = 0x1; // product
|
||||
|
@ -76,7 +76,7 @@ Handler::Handler(Core::Timing& timing) : timing(timing) {
|
|||
shared_page.battery_state.is_adapter_connected.Assign(1);
|
||||
shared_page.battery_state.is_charging.Assign(1);
|
||||
|
||||
init_time = GetInitTime();
|
||||
init_time = GetInitTime(override_init_time);
|
||||
|
||||
using namespace std::placeholders;
|
||||
update_time_event = timing.RegisterEvent("SharedPage::UpdateTimeCallback",
|
||||
|
|
|
@ -86,7 +86,7 @@ static_assert(sizeof(SharedPageDef) == Memory::SHARED_PAGE_SIZE,
|
|||
|
||||
class Handler : public BackingMem {
|
||||
public:
|
||||
Handler(Core::Timing& timing);
|
||||
Handler(Core::Timing& timing, u64 override_init_time);
|
||||
|
||||
void SetMacAddress(const MacAddress&);
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <fmt/format.h>
|
||||
#include "common/archives.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/microprofile.h"
|
||||
#include "common/scm_rev.h"
|
||||
|
@ -38,7 +39,6 @@
|
|||
#include "core/hle/lock.h"
|
||||
#include "core/hle/result.h"
|
||||
#include "core/hle/service/plgldr/plgldr.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <boost/serialization/split_member.hpp>
|
||||
#include "common/common_types.h"
|
||||
#include "common/memory_ref.h"
|
||||
#include "core/hle/kernel/memory.h"
|
||||
#include "core/hle/result.h"
|
||||
#include "core/memory.h"
|
||||
#include "core/mmio.h"
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "core/core.h"
|
||||
#include "core/hle/ipc_helpers.h"
|
||||
#include "core/hle/kernel/shared_memory.h"
|
||||
#include "core/hle/service/act/act.h"
|
||||
#include "core/hle/service/act/act_a.h"
|
||||
#include "core/hle/service/act/act_u.h"
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "common/archives.h"
|
||||
#include "common/file_util.h"
|
||||
#include "common/settings.h"
|
||||
#include "core/core.h"
|
||||
#include "core/frontend/input.h"
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include "core/hle/service/service.h"
|
||||
#include "core/hw/aes/ccm.h"
|
||||
#include "core/hw/aes/key.h"
|
||||
#include "core/loader/loader.h"
|
||||
#include "core/telemetry_session.h"
|
||||
|
||||
SERVICE_CONSTRUCT_IMPL(Service::APT::Module)
|
||||
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
#include <array>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
#include "common/archives.h"
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/string_util.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/ipc_helpers.h"
|
||||
#include "core/hle/kernel/event.h"
|
||||
|
|
|
@ -150,7 +150,7 @@ void Module::UpdatePadCallback(std::uintptr_t user_data, s64 cycles_late) {
|
|||
circle_pad_old_y.erase(circle_pad_old_y.begin());
|
||||
circle_pad_old_y.push_back(circle_pad_new_y);
|
||||
|
||||
Core::Movie::GetInstance().HandlePadAndCircleStatus(state, circle_pad_x, circle_pad_y);
|
||||
system.Movie().HandlePadAndCircleStatus(state, circle_pad_x, circle_pad_y);
|
||||
|
||||
const DirectionState direction = GetStickDirectionState(circle_pad_x, circle_pad_y);
|
||||
state.circle_up.Assign(direction.up);
|
||||
|
@ -200,7 +200,7 @@ void Module::UpdatePadCallback(std::uintptr_t user_data, s64 cycles_late) {
|
|||
touch_entry.y = static_cast<u16>(y * Core::kScreenBottomHeight);
|
||||
touch_entry.valid.Assign(pressed ? 1 : 0);
|
||||
|
||||
Core::Movie::GetInstance().HandleTouchStatus(touch_entry);
|
||||
system.Movie().HandleTouchStatus(touch_entry);
|
||||
|
||||
// TODO(bunnei): We're not doing anything with offset 0xA8 + 0x18 of HID SharedMemory, which
|
||||
// supposedly is "Touch-screen entry, which contains the raw coordinate data prior to being
|
||||
|
@ -246,7 +246,7 @@ void Module::UpdateAccelerometerCallback(std::uintptr_t user_data, s64 cycles_la
|
|||
accelerometer_entry.y = static_cast<s16>(accel.y);
|
||||
accelerometer_entry.z = static_cast<s16>(accel.z);
|
||||
|
||||
Core::Movie::GetInstance().HandleAccelerometerStatus(accelerometer_entry);
|
||||
system.Movie().HandleAccelerometerStatus(accelerometer_entry);
|
||||
|
||||
// Make up "raw" entry
|
||||
// TODO(wwylele):
|
||||
|
@ -287,7 +287,7 @@ void Module::UpdateGyroscopeCallback(std::uintptr_t user_data, s64 cycles_late)
|
|||
gyroscope_entry.y = static_cast<s16>(gyro.y);
|
||||
gyroscope_entry.z = static_cast<s16>(gyro.z);
|
||||
|
||||
Core::Movie::GetInstance().HandleGyroscopeStatus(gyroscope_entry);
|
||||
system.Movie().HandleGyroscopeStatus(gyroscope_entry);
|
||||
|
||||
// Make up "raw" entry
|
||||
mem->gyroscope.raw_entry.x = gyroscope_entry.x;
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
#include <fmt/format.h>
|
||||
#include "common/alignment.h"
|
||||
#include "common/settings.h"
|
||||
#include "common/string_util.h"
|
||||
#include "core/core.h"
|
||||
#include "core/core_timing.h"
|
||||
#include "core/hle/service/ir/extra_hid.h"
|
||||
#include "core/movie.h"
|
||||
|
@ -65,7 +63,8 @@ enum class ResponseID : u8 {
|
|||
ReadCalibrationData = 0x11,
|
||||
};
|
||||
|
||||
ExtraHID::ExtraHID(SendFunc send_func, Core::Timing& timing) : IRDevice(send_func), timing(timing) {
|
||||
ExtraHID::ExtraHID(SendFunc send_func, Core::Timing& timing_, Core::Movie& movie_)
|
||||
: IRDevice(send_func), timing{timing_}, movie{movie_} {
|
||||
LoadInputDevices();
|
||||
|
||||
// The data below was retrieved from a New 3DS
|
||||
|
@ -249,7 +248,7 @@ void ExtraHID::SendHIDStatus() {
|
|||
response.buttons.r_not_held.Assign(1);
|
||||
response.unknown = 0;
|
||||
|
||||
Core::Movie::GetInstance().HandleExtraHidResponse(response);
|
||||
movie.HandleExtraHidResponse(response);
|
||||
|
||||
std::vector<u8> response_buffer(sizeof(response));
|
||||
memcpy(response_buffer.data(), &response, sizeof(response));
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
namespace Core {
|
||||
struct TimingEventType;
|
||||
class Timing;
|
||||
class Movie;
|
||||
} // namespace Core
|
||||
|
||||
namespace Service::IR {
|
||||
|
@ -43,7 +44,7 @@ static_assert(sizeof(ExtraHIDResponse) == 6, "HID status response has wrong size
|
|||
*/
|
||||
class ExtraHID final : public IRDevice {
|
||||
public:
|
||||
explicit ExtraHID(SendFunc send_func, Core::Timing& timing);
|
||||
explicit ExtraHID(SendFunc send_func, Core::Timing& timing, Core::Movie& movie);
|
||||
~ExtraHID();
|
||||
|
||||
void OnConnect() override;
|
||||
|
@ -60,6 +61,7 @@ private:
|
|||
void LoadInputDevices();
|
||||
|
||||
Core::Timing& timing;
|
||||
Core::Movie& movie;
|
||||
u8 hid_period;
|
||||
Core::TimingEventType* hid_polling_callback_id;
|
||||
std::array<u8, 0x40> calibration_data;
|
||||
|
|
|
@ -83,7 +83,7 @@ void IR_RST::UpdateCallback(std::uintptr_t user_data, s64 cycles_late) {
|
|||
s16 c_stick_x = static_cast<s16>(c_stick_x_f * MAX_CSTICK_RADIUS);
|
||||
s16 c_stick_y = static_cast<s16>(c_stick_y_f * MAX_CSTICK_RADIUS);
|
||||
|
||||
Core::Movie::GetInstance().HandleIrRst(state, c_stick_x, c_stick_y);
|
||||
system.Movie().HandleIrRst(state, c_stick_x, c_stick_y);
|
||||
|
||||
if (!raw_c_stick) {
|
||||
const HID::DirectionState direction = HID::GetStickDirectionState(c_stick_x, c_stick_y);
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <boost/serialization/shared_ptr.hpp>
|
||||
#include <boost/serialization/unique_ptr.hpp>
|
||||
#include <fmt/format.h>
|
||||
#include "common/string_util.h"
|
||||
#include "common/archives.h"
|
||||
#include "common/swap.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/ipc_helpers.h"
|
||||
|
@ -467,7 +467,7 @@ IR_USER::IR_USER(Core::System& system) : ServiceFramework("ir:USER", 1) {
|
|||
receive_event = system.Kernel().CreateEvent(ResetType::OneShot, "IR:ReceiveEvent");
|
||||
|
||||
extra_hid = std::make_unique<ExtraHID>([this](std::span<const u8> data) { PutToReceive(data); },
|
||||
system.CoreTiming());
|
||||
system.CoreTiming(), system.Movie());
|
||||
}
|
||||
|
||||
IR_USER::~IR_USER() {
|
||||
|
|
|
@ -7,13 +7,14 @@
|
|||
#include <boost/crc.hpp>
|
||||
#include <cryptopp/osrng.h>
|
||||
|
||||
#include "common/file_util.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/string_util.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/kernel/shared_page.h"
|
||||
#include "core/hle/service/nfc/amiibo_crypto.h"
|
||||
#include "core/hle/service/nfc/nfc_device.h"
|
||||
#include "core/hw/aes/key.h"
|
||||
#include "core/loader/loader.h"
|
||||
|
||||
SERVICE_CONSTRUCT_IMPL(Service::NFC::NfcDevice)
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "common/string_util.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/ipc_helpers.h"
|
||||
#include "core/hle/kernel/event.h"
|
||||
#include "core/hle/service/nim/nim_u.h"
|
||||
|
||||
SERVICE_CONSTRUCT_IMPL(Service::NIM::NIM_U)
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "core/hle/service/soc_u.h"
|
||||
#include "core/hle/service/ssl_c.h"
|
||||
#include "core/hle/service/y2r_u.h"
|
||||
#include "core/loader/loader.h"
|
||||
|
||||
namespace Service {
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include "common/file_util.h"
|
||||
#include "core/file_sys/romfs_reader.h"
|
||||
#include "core/hle/kernel/kernel.h"
|
||||
#include "core/hle/kernel/object.h"
|
||||
|
||||
namespace Kernel {
|
||||
struct AddressMapping;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "core/loader/smdh.h"
|
||||
#include "core/memory.h"
|
||||
#include "core/system_titles.h"
|
||||
#include "core/telemetry_session.h"
|
||||
#include "network/network.h"
|
||||
|
||||
namespace Loader {
|
||||
|
|
|
@ -10,13 +10,11 @@
|
|||
#include <boost/optional.hpp>
|
||||
#include <cryptopp/hex.h>
|
||||
#include <cryptopp/osrng.h>
|
||||
#include <fmt/format.h>
|
||||
#include "common/archives.h"
|
||||
#include "common/bit_field.h"
|
||||
#include "common/common_types.h"
|
||||
#include "common/file_util.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/scm_rev.h"
|
||||
#include "common/string_util.h"
|
||||
#include "common/swap.h"
|
||||
#include "common/timer.h"
|
||||
#include "core/core.h"
|
||||
|
@ -24,12 +22,11 @@
|
|||
#include "core/hle/service/ir/extra_hid.h"
|
||||
#include "core/hle/service/ir/ir_rst.h"
|
||||
#include "core/hw/gpu.h"
|
||||
#include "core/loader/loader.h"
|
||||
#include "core/movie.h"
|
||||
|
||||
namespace Core {
|
||||
|
||||
/*static*/ Movie Movie::s_instance;
|
||||
|
||||
enum class ControllerStateType : u8 {
|
||||
PadAndCircle,
|
||||
Touch,
|
||||
|
@ -146,6 +143,10 @@ static u64 GetInputCount(std::span<const u8> input) {
|
|||
return input_count;
|
||||
}
|
||||
|
||||
Movie::Movie(const Core::System& system_) : system{system_} {}
|
||||
|
||||
Movie::~Movie() = default;
|
||||
|
||||
template <class Archive>
|
||||
void Movie::serialize(Archive& ar, const unsigned int file_version) {
|
||||
// Only serialize what's needed to make savestates useful for TAS:
|
||||
|
@ -565,7 +566,7 @@ void Movie::StartRecording(const std::string& movie_file, const std::string& aut
|
|||
|
||||
// Get program ID
|
||||
program_id = 0;
|
||||
Core::System::GetInstance().GetAppLoader().ReadProgramId(program_id);
|
||||
system.GetAppLoader().ReadProgramId(program_id);
|
||||
|
||||
LOG_INFO(Movie, "Enabling Movie recording, ID: {:016X}", id);
|
||||
}
|
||||
|
|
|
@ -23,25 +23,29 @@ union PadState;
|
|||
} // namespace Service
|
||||
|
||||
namespace Core {
|
||||
|
||||
class System;
|
||||
struct CTMHeader;
|
||||
struct ControllerState;
|
||||
|
||||
class Movie {
|
||||
public:
|
||||
enum class PlayMode { None, Recording, Playing, MovieFinished };
|
||||
enum class ValidationResult {
|
||||
enum class PlayMode : u32 {
|
||||
None,
|
||||
Recording,
|
||||
Playing,
|
||||
MovieFinished,
|
||||
};
|
||||
|
||||
enum class ValidationResult : u32 {
|
||||
OK,
|
||||
RevisionDismatch,
|
||||
InputCountDismatch,
|
||||
Invalid,
|
||||
};
|
||||
/**
|
||||
* Gets the instance of the Movie singleton class.
|
||||
* @returns Reference to the instance of the Movie singleton class.
|
||||
*/
|
||||
static Movie& GetInstance() {
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
explicit Movie(const Core::System& system);
|
||||
~Movie();
|
||||
|
||||
void SetPlaybackCompletionCallback(std::function<void()> completion_callback);
|
||||
void StartPlayback(const std::string& movie_file);
|
||||
|
@ -133,8 +137,6 @@ public:
|
|||
void SaveMovie();
|
||||
|
||||
private:
|
||||
static Movie s_instance;
|
||||
|
||||
void CheckInputEnd();
|
||||
|
||||
template <typename... Targs>
|
||||
|
@ -159,6 +161,8 @@ private:
|
|||
ValidationResult ValidateHeader(const CTMHeader& header) const;
|
||||
ValidationResult ValidateInput(std::span<const u8> input, u64 expected_count) const;
|
||||
|
||||
private:
|
||||
const Core::System& system;
|
||||
PlayMode play_mode;
|
||||
|
||||
std::string record_movie_file;
|
||||
|
|
|
@ -3,11 +3,14 @@
|
|||
// Refer to the license.txt file included.
|
||||
|
||||
#include <chrono>
|
||||
#include <sstream>
|
||||
#include <cryptopp/hex.h>
|
||||
#include <fmt/format.h>
|
||||
#include "common/archives.h"
|
||||
#include "common/file_util.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/scm_rev.h"
|
||||
#include "common/swap.h"
|
||||
#include "common/zstd_compression.h"
|
||||
#include "core/core.h"
|
||||
#include "core/movie.h"
|
||||
|
@ -30,8 +33,7 @@ static_assert(sizeof(CSTHeader) == 256, "CSTHeader should be 256 bytes");
|
|||
|
||||
constexpr std::array<u8, 4> header_magic_bytes{{'C', 'S', 'T', 0x1B}};
|
||||
|
||||
static std::string GetSaveStatePath(u64 program_id, u32 slot) {
|
||||
const u64 movie_id = Movie::GetInstance().GetCurrentMovieID();
|
||||
static std::string GetSaveStatePath(u64 program_id, u64 movie_id, u32 slot) {
|
||||
if (movie_id) {
|
||||
return fmt::format("{}{:016X}.movie{:016X}.{:02d}.cst",
|
||||
FileUtil::GetUserPath(FileUtil::UserPath::StatesDir), program_id,
|
||||
|
@ -43,8 +45,8 @@ static std::string GetSaveStatePath(u64 program_id, u32 slot) {
|
|||
}
|
||||
|
||||
static bool ValidateSaveState(const CSTHeader& header, SaveStateInfo& info, u64 program_id,
|
||||
u32 slot) {
|
||||
const auto path = GetSaveStatePath(program_id, slot);
|
||||
u64 movie_id, u32 slot) {
|
||||
const auto path = GetSaveStatePath(program_id, movie_id, slot);
|
||||
if (header.filetype != header_magic_bytes) {
|
||||
LOG_WARNING(Core, "Invalid save state file {}", path);
|
||||
return false;
|
||||
|
@ -66,11 +68,11 @@ static bool ValidateSaveState(const CSTHeader& header, SaveStateInfo& info, u64
|
|||
return true;
|
||||
}
|
||||
|
||||
std::vector<SaveStateInfo> ListSaveStates(u64 program_id) {
|
||||
std::vector<SaveStateInfo> ListSaveStates(u64 program_id, u64 movie_id) {
|
||||
std::vector<SaveStateInfo> result;
|
||||
result.reserve(SaveStateSlotCount);
|
||||
for (u32 slot = 1; slot <= SaveStateSlotCount; ++slot) {
|
||||
const auto path = GetSaveStatePath(program_id, slot);
|
||||
const auto path = GetSaveStatePath(program_id, movie_id, slot);
|
||||
if (!FileUtil::Exists(path)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -92,7 +94,7 @@ std::vector<SaveStateInfo> ListSaveStates(u64 program_id) {
|
|||
LOG_ERROR(Core, "Could not read from file {}", path);
|
||||
continue;
|
||||
}
|
||||
if (!ValidateSaveState(header, info, program_id, slot)) {
|
||||
if (!ValidateSaveState(header, info, program_id, movie_id, slot)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -111,7 +113,8 @@ void System::SaveState(u32 slot) const {
|
|||
const auto data = std::span<const u8>{reinterpret_cast<const u8*>(str.data()), str.size()};
|
||||
auto buffer = Common::Compression::CompressDataZSTDDefault(data);
|
||||
|
||||
const auto path = GetSaveStatePath(title_id, slot);
|
||||
const u64 movie_id = movie.GetCurrentMovieID();
|
||||
const auto path = GetSaveStatePath(title_id, movie_id, slot);
|
||||
if (!FileUtil::CreateFullPath(path)) {
|
||||
throw std::runtime_error("Could not create path " + path);
|
||||
}
|
||||
|
@ -143,7 +146,8 @@ void System::LoadState(u32 slot) {
|
|||
throw std::runtime_error("Unable to load while connected to multiplayer");
|
||||
}
|
||||
|
||||
const auto path = GetSaveStatePath(title_id, slot);
|
||||
const u64 movie_id = movie.GetCurrentMovieID();
|
||||
const auto path = GetSaveStatePath(title_id, movie_id, slot);
|
||||
|
||||
std::vector<u8> decompressed;
|
||||
{
|
||||
|
@ -159,7 +163,7 @@ void System::LoadState(u32 slot) {
|
|||
|
||||
// validate header
|
||||
SaveStateInfo info;
|
||||
if (!ValidateSaveState(header, info, title_id, slot)) {
|
||||
if (!ValidateSaveState(header, info, title_id, movie_id, slot)) {
|
||||
throw std::runtime_error("Invalid savestate");
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,6 @@ struct SaveStateInfo {
|
|||
|
||||
constexpr u32 SaveStateSlotCount = 10; // Maximum count of savestate slots
|
||||
|
||||
std::vector<SaveStateInfo> ListSaveStates(u64 program_id);
|
||||
std::vector<SaveStateInfo> ListSaveStates(u64 program_id, u64 movie_id);
|
||||
|
||||
} // namespace Core
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "common/scm_rev.h"
|
||||
#include "common/settings.h"
|
||||
#include "core/core.h"
|
||||
#include "core/loader/loader.h"
|
||||
#include "core/telemetry_session.h"
|
||||
#include "network/network_settings.h"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue