2024-02-25 08:20:34 +00:00
|
|
|
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
|
2024-09-01 12:08:31 +00:00
|
|
|
// SPDX-License-Identifier: PolyForm-Strict-1.0.0
|
2022-12-04 11:03:45 +00:00
|
|
|
|
2019-09-09 07:01:26 +00:00
|
|
|
#pragma once
|
2024-04-13 09:56:08 +00:00
|
|
|
|
2020-09-29 13:29:28 +00:00
|
|
|
#include "settings.h"
|
2020-01-24 04:51:05 +00:00
|
|
|
#include "types.h"
|
2024-04-13 09:56:08 +00:00
|
|
|
|
2024-07-29 06:23:39 +00:00
|
|
|
#include "util/image.h"
|
|
|
|
|
2019-09-20 06:47:41 +00:00
|
|
|
#include <memory>
|
2019-11-16 05:27:57 +00:00
|
|
|
#include <optional>
|
2020-01-24 04:51:05 +00:00
|
|
|
#include <string>
|
2019-09-09 07:01:26 +00:00
|
|
|
|
2019-09-14 10:28:47 +00:00
|
|
|
class ByteStream;
|
2019-11-16 05:27:57 +00:00
|
|
|
class CDImage;
|
2024-02-25 08:20:34 +00:00
|
|
|
class Error;
|
2024-04-13 09:56:08 +00:00
|
|
|
class SmallStringBase;
|
2019-09-14 10:28:47 +00:00
|
|
|
class StateWrapper;
|
2024-05-25 13:49:19 +00:00
|
|
|
class SocketMultiplexer;
|
2019-09-14 10:28:47 +00:00
|
|
|
|
2024-05-23 15:59:35 +00:00
|
|
|
enum class GPUVSyncMode : u8;
|
|
|
|
|
2019-12-08 14:51:52 +00:00
|
|
|
class Controller;
|
2019-09-12 02:53:04 +00:00
|
|
|
|
2020-09-09 12:11:28 +00:00
|
|
|
struct CheatCode;
|
|
|
|
class CheatList;
|
|
|
|
|
2023-08-30 07:38:17 +00:00
|
|
|
class GPUTexture;
|
2024-08-11 10:45:14 +00:00
|
|
|
class MediaCapture;
|
2023-08-30 07:38:17 +00:00
|
|
|
|
|
|
|
namespace BIOS {
|
2023-03-16 09:22:54 +00:00
|
|
|
struct ImageInfo;
|
2023-08-30 07:38:17 +00:00
|
|
|
} // namespace BIOS
|
2023-03-16 09:22:54 +00:00
|
|
|
|
2023-09-03 04:30:26 +00:00
|
|
|
namespace GameDatabase {
|
2023-08-23 08:12:10 +00:00
|
|
|
struct Entry;
|
|
|
|
}
|
|
|
|
|
2020-03-02 01:08:16 +00:00
|
|
|
struct SystemBootParameters
|
|
|
|
{
|
|
|
|
SystemBootParameters();
|
2022-07-11 13:03:29 +00:00
|
|
|
SystemBootParameters(const SystemBootParameters&);
|
|
|
|
SystemBootParameters(SystemBootParameters&&);
|
2020-03-02 01:08:16 +00:00
|
|
|
SystemBootParameters(std::string filename_);
|
|
|
|
~SystemBootParameters();
|
|
|
|
|
|
|
|
std::string filename;
|
2022-07-11 13:03:29 +00:00
|
|
|
std::string save_state;
|
2023-01-11 09:40:56 +00:00
|
|
|
std::string override_exe;
|
2020-03-02 01:08:16 +00:00
|
|
|
std::optional<bool> override_fast_boot;
|
2020-04-13 12:13:46 +00:00
|
|
|
std::optional<bool> override_fullscreen;
|
2020-12-26 14:28:04 +00:00
|
|
|
std::optional<bool> override_start_paused;
|
2020-07-22 16:36:05 +00:00
|
|
|
u32 media_playlist_index = 0;
|
|
|
|
bool load_image_to_ram = false;
|
2020-06-28 15:51:01 +00:00
|
|
|
bool force_software_renderer = false;
|
2023-11-26 14:45:00 +00:00
|
|
|
bool disable_achievements_hardcore_mode = false;
|
2024-08-11 10:45:14 +00:00
|
|
|
bool start_media_capture = false;
|
2020-03-02 01:08:16 +00:00
|
|
|
};
|
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
struct SaveStateInfo
|
|
|
|
{
|
|
|
|
std::string path;
|
|
|
|
std::time_t timestamp;
|
|
|
|
s32 slot;
|
|
|
|
bool global;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ExtendedSaveStateInfo
|
|
|
|
{
|
|
|
|
std::string title;
|
2022-10-05 08:29:08 +00:00
|
|
|
std::string serial;
|
2022-07-11 13:03:29 +00:00
|
|
|
std::string media_path;
|
|
|
|
std::time_t timestamp;
|
|
|
|
|
2024-07-29 06:23:39 +00:00
|
|
|
RGBA8Image screenshot;
|
2022-07-11 13:03:29 +00:00
|
|
|
};
|
|
|
|
|
2020-07-31 07:09:18 +00:00
|
|
|
namespace System {
|
2020-02-05 08:43:00 +00:00
|
|
|
|
2023-09-03 04:30:26 +00:00
|
|
|
enum : s32
|
|
|
|
{
|
2022-07-11 13:03:29 +00:00
|
|
|
PER_GAME_SAVE_STATE_SLOTS = 10,
|
|
|
|
GLOBAL_SAVE_STATE_SLOTS = 10
|
2020-07-31 07:09:18 +00:00
|
|
|
};
|
2020-07-22 16:36:05 +00:00
|
|
|
|
2020-09-29 13:29:28 +00:00
|
|
|
enum : TickCount
|
|
|
|
{
|
|
|
|
MASTER_CLOCK = 44100 * 0x300 // 33868800Hz or 33.8688MHz, also used as CPU clock
|
|
|
|
};
|
|
|
|
|
2020-07-31 07:09:18 +00:00
|
|
|
enum class State
|
|
|
|
{
|
|
|
|
Shutdown,
|
|
|
|
Starting,
|
|
|
|
Running,
|
2023-08-15 13:12:21 +00:00
|
|
|
Paused,
|
|
|
|
Stopping,
|
2020-07-31 07:09:18 +00:00
|
|
|
};
|
2020-07-22 16:36:05 +00:00
|
|
|
|
2024-07-28 06:16:05 +00:00
|
|
|
enum class BootMode
|
|
|
|
{
|
2024-08-18 02:13:45 +00:00
|
|
|
None,
|
2024-07-28 06:16:05 +00:00
|
|
|
FullBoot,
|
|
|
|
FastBoot,
|
|
|
|
BootEXE,
|
|
|
|
BootPSF,
|
|
|
|
};
|
|
|
|
|
2023-05-15 13:38:37 +00:00
|
|
|
using GameHash = u64;
|
|
|
|
|
2020-09-29 13:29:28 +00:00
|
|
|
extern TickCount g_ticks_per_second;
|
|
|
|
|
2020-09-01 02:29:22 +00:00
|
|
|
/// Returns true if the filename is a PlayStation executable we can inject.
|
2024-05-05 10:21:54 +00:00
|
|
|
bool IsExeFileName(std::string_view path);
|
2020-09-01 02:29:22 +00:00
|
|
|
|
|
|
|
/// Returns true if the filename is a Portable Sound Format file we can uncompress/load.
|
2024-05-05 10:21:54 +00:00
|
|
|
bool IsPsfFileName(std::string_view path);
|
2020-09-01 02:29:22 +00:00
|
|
|
|
2021-02-18 08:07:09 +00:00
|
|
|
/// Returns true if the filename is one we can load.
|
2024-05-05 10:21:54 +00:00
|
|
|
bool IsLoadableFilename(std::string_view path);
|
2022-07-11 13:03:29 +00:00
|
|
|
|
|
|
|
/// Returns true if the filename is a save state.
|
2024-05-05 10:21:54 +00:00
|
|
|
bool IsSaveStateFilename(std::string_view path);
|
2021-02-18 08:07:09 +00:00
|
|
|
|
2020-07-31 07:09:18 +00:00
|
|
|
/// Returns the preferred console type for a disc.
|
|
|
|
ConsoleRegion GetConsoleRegionForDiscRegion(DiscRegion region);
|
2020-07-22 16:36:05 +00:00
|
|
|
|
2023-05-15 13:38:37 +00:00
|
|
|
std::string GetExecutableNameForImage(CDImage* cdi, bool strip_subdirectories);
|
2021-02-21 06:53:29 +00:00
|
|
|
bool ReadExecutableFromImage(CDImage* cdi, std::string* out_executable_name, std::vector<u8>* out_executable_data);
|
|
|
|
|
2023-05-15 13:38:37 +00:00
|
|
|
std::string GetGameHashId(GameHash hash);
|
|
|
|
bool GetGameDetailsFromImage(CDImage* cdi, std::string* out_id, GameHash* out_hash);
|
2024-05-30 12:21:51 +00:00
|
|
|
GameHash GetGameHashFromFile(const char* path);
|
2024-08-02 13:56:06 +00:00
|
|
|
DiscRegion GetRegionForSerial(const std::string_view serial);
|
2020-09-01 02:29:22 +00:00
|
|
|
DiscRegion GetRegionFromSystemArea(CDImage* cdi);
|
|
|
|
DiscRegion GetRegionForImage(CDImage* cdi);
|
2021-01-24 04:05:45 +00:00
|
|
|
DiscRegion GetRegionForExe(const char* path);
|
|
|
|
DiscRegion GetRegionForPsf(const char* path);
|
2020-09-01 02:29:22 +00:00
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
/// Returns the path for the game settings ini file for the specified serial.
|
2024-05-05 10:21:54 +00:00
|
|
|
std::string GetGameSettingsPath(std::string_view game_serial);
|
2022-07-11 13:03:29 +00:00
|
|
|
|
|
|
|
/// Returns the path for the input profile ini file with the specified name (may not exist).
|
2024-05-05 10:21:54 +00:00
|
|
|
std::string GetInputProfilePath(std::string_view name);
|
2022-07-11 13:03:29 +00:00
|
|
|
|
2020-07-31 07:09:18 +00:00
|
|
|
State GetState();
|
|
|
|
void SetState(State new_state);
|
|
|
|
bool IsRunning();
|
|
|
|
bool IsPaused();
|
|
|
|
bool IsShutdown();
|
|
|
|
bool IsValid();
|
2023-10-29 12:46:02 +00:00
|
|
|
bool IsValidOrInitializing();
|
2023-08-29 07:17:57 +00:00
|
|
|
bool IsExecuting();
|
2020-07-22 16:36:05 +00:00
|
|
|
|
2021-02-18 15:48:44 +00:00
|
|
|
bool IsStartupCancelled();
|
|
|
|
void CancelPendingStartup();
|
2023-08-30 12:18:01 +00:00
|
|
|
void InterruptExecution();
|
2021-02-18 15:48:44 +00:00
|
|
|
|
2020-07-31 07:09:18 +00:00
|
|
|
ConsoleRegion GetRegion();
|
2022-07-11 13:03:29 +00:00
|
|
|
DiscRegion GetDiscRegion();
|
2020-07-31 07:09:18 +00:00
|
|
|
bool IsPALRegion();
|
2020-09-29 13:29:28 +00:00
|
|
|
|
|
|
|
ALWAYS_INLINE TickCount GetTicksPerSecond()
|
|
|
|
{
|
|
|
|
return g_ticks_per_second;
|
|
|
|
}
|
|
|
|
|
|
|
|
ALWAYS_INLINE_RELEASE TickCount ScaleTicksToOverclock(TickCount ticks)
|
|
|
|
{
|
|
|
|
if (!g_settings.cpu_overclock_active)
|
|
|
|
return ticks;
|
|
|
|
|
2022-09-17 04:26:37 +00:00
|
|
|
return static_cast<TickCount>(((static_cast<u64>(static_cast<u32>(ticks)) * g_settings.cpu_overclock_numerator) +
|
|
|
|
(g_settings.cpu_overclock_denominator - 1)) /
|
2020-09-29 13:29:28 +00:00
|
|
|
g_settings.cpu_overclock_denominator);
|
|
|
|
}
|
|
|
|
|
|
|
|
ALWAYS_INLINE_RELEASE TickCount UnscaleTicksToOverclock(TickCount ticks, TickCount* remainder)
|
|
|
|
{
|
|
|
|
if (!g_settings.cpu_overclock_active)
|
|
|
|
return ticks;
|
|
|
|
|
|
|
|
const u64 num =
|
|
|
|
(static_cast<u32>(ticks) * static_cast<u64>(g_settings.cpu_overclock_denominator)) + static_cast<u32>(*remainder);
|
|
|
|
const TickCount t = static_cast<u32>(num / g_settings.cpu_overclock_numerator);
|
|
|
|
*remainder = static_cast<u32>(num % g_settings.cpu_overclock_numerator);
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
|
|
|
TickCount GetMaxSliceTicks();
|
|
|
|
void UpdateOverclock();
|
|
|
|
|
2024-08-13 13:52:25 +00:00
|
|
|
GlobalTicks GetGlobalTickCounter();
|
2020-07-31 07:09:18 +00:00
|
|
|
u32 GetFrameNumber();
|
|
|
|
u32 GetInternalFrameNumber();
|
|
|
|
void IncrementInternalFrameNumber();
|
2023-08-15 13:12:21 +00:00
|
|
|
void FrameDone();
|
2020-07-22 16:36:05 +00:00
|
|
|
|
2023-05-15 13:38:37 +00:00
|
|
|
const std::string& GetDiscPath();
|
|
|
|
const std::string& GetGameSerial();
|
|
|
|
const std::string& GetGameTitle();
|
2024-07-28 06:16:05 +00:00
|
|
|
const std::string& GetExeOverride();
|
2023-08-23 08:12:10 +00:00
|
|
|
const GameDatabase::Entry* GetGameDatabaseEntry();
|
2023-05-15 13:38:37 +00:00
|
|
|
GameHash GetGameHash();
|
2023-05-08 03:07:19 +00:00
|
|
|
bool IsRunningUnknownGame();
|
2024-07-28 06:16:05 +00:00
|
|
|
BootMode GetBootMode();
|
2023-05-15 13:38:37 +00:00
|
|
|
|
2023-08-23 12:06:48 +00:00
|
|
|
/// Returns the time elapsed in the current play session.
|
|
|
|
u64 GetSessionPlayedTime();
|
|
|
|
|
2023-03-16 09:22:54 +00:00
|
|
|
const BIOS::ImageInfo* GetBIOSImageInfo();
|
2020-07-22 16:36:05 +00:00
|
|
|
|
2023-01-07 03:09:20 +00:00
|
|
|
static constexpr u32 NUM_FRAME_TIME_SAMPLES = 150;
|
|
|
|
using FrameTimeHistory = std::array<float, NUM_FRAME_TIME_SAMPLES>;
|
|
|
|
|
2020-07-31 07:09:18 +00:00
|
|
|
float GetFPS();
|
|
|
|
float GetVPS();
|
|
|
|
float GetEmulationSpeed();
|
|
|
|
float GetAverageFrameTime();
|
2023-01-07 03:09:20 +00:00
|
|
|
float GetMinimumFrameTime();
|
|
|
|
float GetMaximumFrameTime();
|
2020-07-31 07:09:18 +00:00
|
|
|
float GetThrottleFrequency();
|
2022-07-11 13:03:29 +00:00
|
|
|
float GetCPUThreadUsage();
|
|
|
|
float GetCPUThreadAverageTime();
|
|
|
|
float GetSWThreadUsage();
|
|
|
|
float GetSWThreadAverageTime();
|
2022-09-03 04:15:15 +00:00
|
|
|
float GetGPUUsage();
|
|
|
|
float GetGPUAverageTime();
|
2023-01-07 03:09:20 +00:00
|
|
|
const FrameTimeHistory& GetFrameTimeHistory();
|
|
|
|
u32 GetFrameTimeHistoryPos();
|
2024-04-13 09:56:08 +00:00
|
|
|
void FormatLatencyStats(SmallStringBase& str);
|
2020-07-22 16:36:05 +00:00
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
/// Loads global settings (i.e. EmuConfig).
|
|
|
|
void LoadSettings(bool display_osd_messages);
|
|
|
|
void SetDefaultSettings(SettingsInterface& si);
|
2019-11-16 05:27:57 +00:00
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
/// Reloads settings, and applies any changes present.
|
|
|
|
void ApplySettings(bool display_osd_messages);
|
|
|
|
|
|
|
|
/// Reloads game specific settings, and applys any changes present.
|
|
|
|
bool ReloadGameSettings(bool display_osd_messages);
|
|
|
|
|
2024-05-16 06:48:50 +00:00
|
|
|
/// Reloads input sources.
|
|
|
|
void ReloadInputSources();
|
|
|
|
|
|
|
|
/// Reloads input bindings.
|
|
|
|
void ReloadInputBindings();
|
|
|
|
|
2024-08-23 12:31:59 +00:00
|
|
|
/// Reloads only controller settings.
|
|
|
|
void UpdateControllerSettings();
|
|
|
|
|
2024-04-11 03:42:10 +00:00
|
|
|
bool BootSystem(SystemBootParameters parameters, Error* error);
|
2022-07-11 13:03:29 +00:00
|
|
|
void PauseSystem(bool paused);
|
|
|
|
void ResetSystem();
|
|
|
|
|
2024-07-29 06:23:39 +00:00
|
|
|
/// Loads state from the specified path.
|
|
|
|
bool LoadState(const char* path, Error* error, bool save_undo_state);
|
|
|
|
bool SaveState(const char* path, Error* error, bool backup_existing_save);
|
2024-04-11 03:42:10 +00:00
|
|
|
bool SaveResumeState(Error* error);
|
2022-07-11 13:03:29 +00:00
|
|
|
|
|
|
|
/// Runs the VM until the CPU execution is canceled.
|
|
|
|
void Execute();
|
|
|
|
|
2020-12-16 15:18:02 +00:00
|
|
|
void SingleStepCPU();
|
2020-01-24 04:53:40 +00:00
|
|
|
|
2020-11-03 11:21:11 +00:00
|
|
|
/// Sets target emulation speed.
|
2021-01-12 16:36:11 +00:00
|
|
|
float GetTargetSpeed();
|
2024-05-22 12:28:19 +00:00
|
|
|
float GetAudioNominalRate();
|
2020-11-03 11:21:11 +00:00
|
|
|
|
2020-07-31 07:09:18 +00:00
|
|
|
/// Adjusts the throttle frequency, i.e. how many times we should sleep per second.
|
|
|
|
void SetThrottleFrequency(float frequency);
|
2020-01-24 04:53:40 +00:00
|
|
|
|
2020-07-31 07:09:18 +00:00
|
|
|
// Access controllers for simulating input.
|
|
|
|
Controller* GetController(u32 slot);
|
2021-05-24 09:55:07 +00:00
|
|
|
void UpdateMemoryCardTypes();
|
2021-05-18 04:36:55 +00:00
|
|
|
bool HasMemoryCard(u32 slot);
|
2024-04-21 15:41:42 +00:00
|
|
|
bool IsSavingMemoryCards();
|
2022-07-11 13:03:29 +00:00
|
|
|
|
|
|
|
/// Swaps memory cards in slot 1/2.
|
2021-05-18 04:36:55 +00:00
|
|
|
void SwapMemoryCards();
|
2022-07-11 13:03:29 +00:00
|
|
|
|
2020-08-16 13:20:36 +00:00
|
|
|
/// Dumps RAM to a file.
|
|
|
|
bool DumpRAM(const char* filename);
|
|
|
|
|
2021-01-13 09:24:41 +00:00
|
|
|
/// Dumps video RAM to a file.
|
|
|
|
bool DumpVRAM(const char* filename);
|
|
|
|
|
|
|
|
/// Dumps sound RAM to a file.
|
|
|
|
bool DumpSPURAM(const char* filename);
|
|
|
|
|
2020-07-31 07:09:18 +00:00
|
|
|
bool HasMedia();
|
2021-02-16 16:16:23 +00:00
|
|
|
std::string GetMediaFileName();
|
2020-07-31 07:09:18 +00:00
|
|
|
bool InsertMedia(const char* path);
|
|
|
|
void RemoveMedia();
|
2019-09-14 10:28:47 +00:00
|
|
|
|
2021-03-26 16:19:23 +00:00
|
|
|
/// Returns true if this is a multi-subimage image (e.g. m3u).
|
|
|
|
bool HasMediaSubImages();
|
2020-08-15 10:38:54 +00:00
|
|
|
|
2020-07-31 07:09:18 +00:00
|
|
|
/// Returns the number of entries in the media/disc playlist.
|
2021-03-26 16:19:23 +00:00
|
|
|
u32 GetMediaSubImageCount();
|
2020-01-24 04:51:05 +00:00
|
|
|
|
2020-07-31 07:09:18 +00:00
|
|
|
/// Returns the current image from the media/disc playlist.
|
2021-03-26 16:19:23 +00:00
|
|
|
u32 GetMediaSubImageIndex();
|
2020-01-24 04:51:05 +00:00
|
|
|
|
2021-02-26 14:44:53 +00:00
|
|
|
/// Returns the index of the specified path in the playlist, or UINT32_MAX if it does not exist.
|
2024-05-05 10:21:54 +00:00
|
|
|
u32 GetMediaSubImageIndexForTitle(std::string_view title);
|
2021-02-26 14:44:53 +00:00
|
|
|
|
2020-07-31 07:09:18 +00:00
|
|
|
/// Returns the path to the specified playlist index.
|
2021-03-26 16:19:23 +00:00
|
|
|
std::string GetMediaSubImageTitle(u32 index);
|
2020-02-09 13:16:25 +00:00
|
|
|
|
2020-07-31 07:09:18 +00:00
|
|
|
/// Switches to the specified media/disc playlist index.
|
2021-03-26 16:19:23 +00:00
|
|
|
bool SwitchMediaSubImage(u32 index);
|
2020-07-22 16:36:05 +00:00
|
|
|
|
2020-09-09 12:11:28 +00:00
|
|
|
/// Returns true if there is currently a cheat list.
|
|
|
|
bool HasCheatList();
|
|
|
|
|
|
|
|
/// Accesses the current cheat list.
|
|
|
|
CheatList* GetCheatList();
|
|
|
|
|
|
|
|
/// Applies a single cheat code.
|
|
|
|
void ApplyCheatCode(const CheatCode& code);
|
|
|
|
|
|
|
|
/// Sets or clears the provided cheat list, applying every frame.
|
|
|
|
void SetCheatList(std::unique_ptr<CheatList> cheats);
|
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
/// Updates throttler.
|
|
|
|
void UpdateSpeedLimiterState();
|
|
|
|
|
|
|
|
/// Toggles fast forward state.
|
|
|
|
bool IsFastForwardEnabled();
|
|
|
|
void SetFastForwardEnabled(bool enabled);
|
|
|
|
|
|
|
|
/// Toggles turbo state.
|
|
|
|
bool IsTurboEnabled();
|
|
|
|
void SetTurboEnabled(bool enabled);
|
|
|
|
|
|
|
|
/// Toggles rewind state.
|
|
|
|
bool IsRewinding();
|
|
|
|
void SetRewindState(bool enabled);
|
|
|
|
|
|
|
|
void DoFrameStep();
|
|
|
|
void DoToggleCheats();
|
|
|
|
|
|
|
|
/// Returns the path to a save state file. Specifying an index of -1 is the "resume" save state.
|
2024-05-05 10:21:54 +00:00
|
|
|
std::string GetGameSaveStateFileName(std::string_view serial, s32 slot);
|
2022-07-11 13:03:29 +00:00
|
|
|
|
|
|
|
/// Returns the path to a save state file. Specifying an index of -1 is the "resume" save state.
|
|
|
|
std::string GetGlobalSaveStateFileName(s32 slot);
|
|
|
|
|
|
|
|
/// Returns the most recent resume save state.
|
|
|
|
std::string GetMostRecentResumeSaveStatePath();
|
|
|
|
|
|
|
|
/// Returns the path to the cheat file for the specified game title.
|
|
|
|
std::string GetCheatFileName();
|
|
|
|
|
|
|
|
/// Powers off the system, optionally saving the resume state.
|
|
|
|
void ShutdownSystem(bool save_resume_state);
|
|
|
|
|
|
|
|
/// Returns true if an undo load state exists.
|
|
|
|
bool CanUndoLoadState();
|
|
|
|
|
|
|
|
/// Returns save state info for the undo slot, if present.
|
|
|
|
std::optional<ExtendedSaveStateInfo> GetUndoSaveStateInfo();
|
|
|
|
|
|
|
|
/// Undoes a load state, i.e. restores the state prior to the load.
|
|
|
|
bool UndoLoadState();
|
|
|
|
|
|
|
|
/// Returns a list of save states for the specified game code.
|
2022-10-05 08:29:08 +00:00
|
|
|
std::vector<SaveStateInfo> GetAvailableSaveStates(const char* serial);
|
2022-07-11 13:03:29 +00:00
|
|
|
|
2022-10-05 08:29:08 +00:00
|
|
|
/// Returns save state info if present. If serial is null or empty, assumes global state.
|
|
|
|
std::optional<SaveStateInfo> GetSaveStateInfo(const char* serial, s32 slot);
|
2022-07-11 13:03:29 +00:00
|
|
|
|
|
|
|
/// Returns save state info from opened save state stream.
|
|
|
|
std::optional<ExtendedSaveStateInfo> GetExtendedSaveStateInfo(const char* path);
|
|
|
|
|
|
|
|
/// Deletes save states for the specified game code. If resume is set, the resume state is deleted too.
|
2022-10-05 08:29:08 +00:00
|
|
|
void DeleteSaveStates(const char* serial, bool resume);
|
2022-07-11 13:03:29 +00:00
|
|
|
|
2024-05-14 15:15:54 +00:00
|
|
|
/// Returns the path to the memory card for the specified game, considering game settings.
|
2024-07-10 11:47:02 +00:00
|
|
|
std::string GetGameMemoryCardPath(std::string_view serial, std::string_view path, u32 slot,
|
|
|
|
MemoryCardType* out_type = nullptr);
|
2024-05-14 15:15:54 +00:00
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
/// Returns intended output volume considering fast forwarding.
|
|
|
|
s32 GetAudioOutputVolume();
|
|
|
|
void UpdateVolume();
|
|
|
|
|
2024-03-02 09:08:38 +00:00
|
|
|
/// Saves a screenshot to the specified file. If no file name is provided, one will be generated automatically.
|
|
|
|
bool SaveScreenshot(const char* filename = nullptr, DisplayScreenshotMode mode = g_settings.display_screenshot_mode,
|
|
|
|
DisplayScreenshotFormat format = g_settings.display_screenshot_format,
|
|
|
|
u8 quality = g_settings.display_screenshot_quality, bool compress_on_thread = true);
|
2022-07-11 13:03:29 +00:00
|
|
|
|
2024-08-18 04:12:42 +00:00
|
|
|
#ifndef __ANDROID__
|
|
|
|
|
2024-08-11 10:45:14 +00:00
|
|
|
/// Returns the path that a new media capture would be saved to by default. Safe to call from any thread.
|
|
|
|
std::string GetNewMediaCapturePath(const std::string_view title, const std::string_view container);
|
|
|
|
|
|
|
|
/// Current media capture (if active).
|
|
|
|
MediaCapture* GetMediaCapture();
|
|
|
|
|
|
|
|
/// Media capture (video and/or audio). If no path is provided, one will be generated automatically.
|
2024-08-18 04:12:42 +00:00
|
|
|
bool StartMediaCapture(std::string path = {});
|
|
|
|
bool StartMediaCapture(std::string path, bool capture_video, bool capture_audio);
|
2024-08-11 10:45:14 +00:00
|
|
|
void StopMediaCapture();
|
|
|
|
|
2024-08-18 04:12:42 +00:00
|
|
|
#endif
|
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
/// Loads the cheat list for the current game title from the user directory.
|
2024-03-03 03:43:04 +00:00
|
|
|
bool LoadCheatList();
|
2022-07-11 13:03:29 +00:00
|
|
|
|
|
|
|
/// Loads the cheat list for the current game code from the built-in code database.
|
|
|
|
bool LoadCheatListFromDatabase();
|
|
|
|
|
|
|
|
/// Saves the current cheat list to the game title's file.
|
|
|
|
bool SaveCheatList();
|
|
|
|
|
|
|
|
/// Deletes the cheat list, if present.
|
|
|
|
bool DeleteCheatList();
|
|
|
|
|
|
|
|
/// Removes all cheats from the cheat list.
|
|
|
|
void ClearCheatList(bool save_to_file);
|
|
|
|
|
|
|
|
/// Enables/disabled the specified cheat code.
|
2024-03-03 03:43:04 +00:00
|
|
|
void SetCheatCodeState(u32 index, bool enabled);
|
2022-07-11 13:03:29 +00:00
|
|
|
|
|
|
|
/// Immediately applies the specified cheat code.
|
|
|
|
void ApplyCheatCode(u32 index);
|
|
|
|
|
|
|
|
/// Toggle Widescreen Hack and Aspect Ratio
|
|
|
|
void ToggleWidescreen();
|
|
|
|
|
|
|
|
/// Returns true if fast forwarding or slow motion is currently active.
|
|
|
|
bool IsRunningAtNonStandardSpeed();
|
|
|
|
|
2022-07-26 11:46:18 +00:00
|
|
|
/// Returns true if vsync should be used.
|
2024-05-23 15:59:35 +00:00
|
|
|
GPUVSyncMode GetEffectiveVSyncMode();
|
2024-05-24 12:48:06 +00:00
|
|
|
bool ShouldAllowPresentThrottle();
|
2022-07-26 11:46:18 +00:00
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
/// Quick switch between software and hardware rendering.
|
|
|
|
void ToggleSoftwareRendering();
|
|
|
|
|
|
|
|
/// Resizes the render window to the display size, with an optional scale.
|
|
|
|
/// If the scale is set to 0, the internal resolution will be used, otherwise it is treated as a multiplier to 1x.
|
|
|
|
void RequestDisplaySize(float scale = 0.0f);
|
|
|
|
|
|
|
|
/// Call when host display size changes, use with "match display" aspect ratio setting.
|
|
|
|
void HostDisplayResized();
|
|
|
|
|
2023-08-30 10:34:48 +00:00
|
|
|
/// Renders the display.
|
2024-09-07 02:53:55 +00:00
|
|
|
bool PresentDisplay(bool explicit_present);
|
2023-08-30 10:34:48 +00:00
|
|
|
void InvalidateDisplay();
|
|
|
|
|
2021-01-23 09:00:54 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// Memory Save States (Rewind and Runahead)
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
2023-12-18 10:36:07 +00:00
|
|
|
void CalculateRewindMemoryUsage(u32 num_saves, u32 resolution_scale, u64* ram_usage, u64* vram_usage);
|
2021-01-23 09:00:54 +00:00
|
|
|
void ClearMemorySaveStates();
|
2021-01-23 16:52:52 +00:00
|
|
|
void SetRunaheadReplayFlag();
|
2021-01-23 09:00:54 +00:00
|
|
|
|
2024-05-25 13:49:19 +00:00
|
|
|
/// Shared socket multiplexer, used by PINE/GDB/etc.
|
|
|
|
SocketMultiplexer* GetSocketMultiplexer();
|
|
|
|
void ReleaseSocketMultiplexer();
|
|
|
|
|
2023-09-07 10:13:48 +00:00
|
|
|
/// Called when rich presence changes.
|
2024-07-04 04:40:16 +00:00
|
|
|
void UpdateRichPresence(bool update_session_time);
|
2023-09-07 10:13:48 +00:00
|
|
|
|
2023-09-03 04:30:26 +00:00
|
|
|
namespace Internal {
|
2024-05-16 07:24:42 +00:00
|
|
|
/// Performs mandatory hardware checks.
|
|
|
|
bool PerformEarlyHardwareChecks(Error* error);
|
|
|
|
|
2024-06-29 08:12:30 +00:00
|
|
|
/// Called on process startup, as early as possible.
|
|
|
|
bool ProcessStartup(Error* error);
|
2023-08-23 12:06:48 +00:00
|
|
|
|
|
|
|
/// Called on process shutdown.
|
2024-06-29 08:12:30 +00:00
|
|
|
void ProcessShutdown();
|
|
|
|
|
|
|
|
/// Called on CPU thread initialization.
|
|
|
|
bool CPUThreadInitialize(Error* error);
|
|
|
|
|
|
|
|
/// Called on CPU thread shutdown.
|
2024-04-25 02:56:02 +00:00
|
|
|
void CPUThreadShutdown();
|
2023-08-23 12:06:48 +00:00
|
|
|
|
|
|
|
/// Polls input, updates subsystems which are present while paused/inactive.
|
|
|
|
void IdlePollUpdate();
|
2023-09-03 04:30:26 +00:00
|
|
|
} // namespace Internal
|
2023-08-23 12:06:48 +00:00
|
|
|
|
2020-07-31 07:09:18 +00:00
|
|
|
} // namespace System
|
2022-07-11 13:03:29 +00:00
|
|
|
|
|
|
|
namespace Host {
|
|
|
|
/// Called with the settings lock held, when system settings are being loaded (should load input sources, etc).
|
|
|
|
void LoadSettings(SettingsInterface& si, std::unique_lock<std::mutex>& lock);
|
|
|
|
|
|
|
|
/// Called after settings are updated.
|
|
|
|
void CheckForSettingsChanges(const Settings& old_settings);
|
|
|
|
|
|
|
|
/// Called when the VM is starting initialization, but has not been completed yet.
|
|
|
|
void OnSystemStarting();
|
|
|
|
|
|
|
|
/// Called when the VM is created.
|
|
|
|
void OnSystemStarted();
|
|
|
|
|
|
|
|
/// Called when the VM is shut down or destroyed.
|
|
|
|
void OnSystemDestroyed();
|
|
|
|
|
|
|
|
/// Called when the VM is paused.
|
|
|
|
void OnSystemPaused();
|
|
|
|
|
|
|
|
/// Called when the VM is resumed after being paused.
|
|
|
|
void OnSystemResumed();
|
|
|
|
|
2023-12-14 06:07:57 +00:00
|
|
|
/// Called when the pause state changes, or fullscreen UI opens.
|
|
|
|
void OnIdleStateChanged();
|
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
/// Called when performance metrics are updated, approximately once a second.
|
|
|
|
void OnPerformanceCountersUpdated();
|
|
|
|
|
|
|
|
/// Provided by the host; called when the running executable changes.
|
|
|
|
void OnGameChanged(const std::string& disc_path, const std::string& game_serial, const std::string& game_name);
|
|
|
|
|
2024-08-11 10:45:14 +00:00
|
|
|
/// Called when media capture starts/stops.
|
|
|
|
void OnMediaCaptureStarted();
|
|
|
|
void OnMediaCaptureStopped();
|
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
/// Provided by the host; called once per frame at guest vsync.
|
|
|
|
void PumpMessagesOnCPUThread();
|
|
|
|
|
|
|
|
/// Requests a specific display window size.
|
|
|
|
void RequestResizeHostDisplay(s32 width, s32 height);
|
|
|
|
|
|
|
|
/// Requests shut down of the current virtual machine.
|
2022-10-03 12:18:49 +00:00
|
|
|
void RequestSystemShutdown(bool allow_confirm, bool save_state);
|
2022-07-11 13:03:29 +00:00
|
|
|
} // namespace Host
|