2023-05-15 13:38:37 +00:00
|
|
|
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
|
2022-12-04 11:03:45 +00:00
|
|
|
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
|
|
|
|
2019-09-09 07:01:26 +00:00
|
|
|
#pragma once
|
2020-02-09 13:16:25 +00:00
|
|
|
#include "common/timer.h"
|
2020-09-29 13:29:28 +00:00
|
|
|
#include "settings.h"
|
2020-01-24 04:53:40 +00:00
|
|
|
#include "timing_event.h"
|
2020-01-24 04:51:05 +00:00
|
|
|
#include "types.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;
|
2019-09-14 10:28:47 +00:00
|
|
|
class StateWrapper;
|
|
|
|
|
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;
|
|
|
|
class GrowableMemoryByteStream;
|
|
|
|
|
|
|
|
namespace BIOS {
|
2023-03-16 09:22:54 +00:00
|
|
|
struct ImageInfo;
|
|
|
|
struct Hash;
|
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;
|
2023-08-30 07:39:41 +00:00
|
|
|
std::string override_bios;
|
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-08-15 13:12:21 +00:00
|
|
|
bool fast_forward_to_first_frame = false;
|
2023-11-26 14:45:00 +00:00
|
|
|
bool disable_achievements_hardcore_mode = 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;
|
|
|
|
|
|
|
|
u32 screenshot_width;
|
|
|
|
u32 screenshot_height;
|
|
|
|
std::vector<u32> screenshot_data;
|
|
|
|
};
|
|
|
|
|
2020-07-31 07:09:18 +00:00
|
|
|
namespace System {
|
2020-02-05 08:43:00 +00:00
|
|
|
|
2020-07-31 07:09:18 +00:00
|
|
|
enum : u32
|
|
|
|
{
|
2021-05-14 06:43:26 +00:00
|
|
|
// 5 megabytes is sufficient for now, at the moment they're around 4.3MB, or 10.3MB with 8MB RAM enabled.
|
2022-07-11 13:03:29 +00:00
|
|
|
MAX_SAVE_STATE_SIZE = 11 * 1024 * 1024,
|
2023-09-03 04:30:26 +00:00
|
|
|
};
|
2022-07-11 13:03:29 +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
|
|
|
|
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.
|
2022-07-11 13:03:29 +00:00
|
|
|
bool IsExeFileName(const 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.
|
2022-07-11 13:03:29 +00:00
|
|
|
bool IsPsfFileName(const 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.
|
2022-07-11 13:03:29 +00:00
|
|
|
bool IsLoadableFilename(const std::string_view& path);
|
|
|
|
|
|
|
|
/// Returns true if the filename is a save state.
|
|
|
|
bool IsSaveStateFilename(const 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);
|
2022-10-05 08:29:08 +00:00
|
|
|
DiscRegion GetRegionForSerial(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
|
|
|
std::optional<DiscRegion> GetRegionForPath(const char* image_path);
|
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
/// Returns the path for the game settings ini file for the specified serial.
|
|
|
|
std::string GetGameSettingsPath(const std::string_view& game_serial);
|
|
|
|
|
|
|
|
/// Returns the path for the input profile ini file with the specified name (may not exist).
|
|
|
|
std::string GetInputProfilePath(const std::string_view& name);
|
|
|
|
|
2020-07-31 07:09:18 +00:00
|
|
|
State GetState();
|
|
|
|
void SetState(State new_state);
|
|
|
|
bool IsRunning();
|
2023-08-15 13:12:21 +00:00
|
|
|
bool IsExecutionInterrupted();
|
2020-07-31 07:09:18 +00:00
|
|
|
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();
|
|
|
|
|
2021-01-24 03:17:22 +00:00
|
|
|
/// Injects a PS-EXE into memory at its specified load location. If patch_loader is set, the BIOS will be patched to
|
|
|
|
/// direct execution to this executable.
|
|
|
|
bool InjectEXEFromBuffer(const void* buffer, u32 buffer_size, bool patch_loader = true);
|
|
|
|
|
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();
|
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();
|
2023-08-15 13:12:21 +00:00
|
|
|
bool WasFastBooted();
|
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();
|
|
|
|
const BIOS::Hash& GetBIOSHash();
|
2020-07-22 16:36:05 +00:00
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
// TODO: Move to PerformanceMetrics
|
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();
|
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);
|
|
|
|
|
|
|
|
bool BootSystem(SystemBootParameters parameters);
|
|
|
|
void PauseSystem(bool paused);
|
|
|
|
void ResetSystem();
|
|
|
|
|
|
|
|
/// Loads state from the specified filename.
|
|
|
|
bool LoadState(const char* filename);
|
|
|
|
bool SaveState(const char* filename, bool backup_existing_save);
|
2022-08-05 07:07:07 +00:00
|
|
|
bool SaveResumeState();
|
2022-07-11 13:03:29 +00:00
|
|
|
|
2023-08-30 07:38:17 +00:00
|
|
|
/// Memory save states - only for internal use.
|
|
|
|
struct MemorySaveState
|
|
|
|
{
|
|
|
|
std::unique_ptr<GPUTexture> vram_texture;
|
|
|
|
std::unique_ptr<GrowableMemoryByteStream> state_stream;
|
|
|
|
};
|
|
|
|
bool SaveMemoryState(MemorySaveState* mss);
|
|
|
|
bool LoadMemoryState(const MemorySaveState& mss);
|
|
|
|
bool LoadStateFromStream(ByteStream* stream, bool update_display, bool ignore_media = false);
|
|
|
|
bool SaveStateToStream(ByteStream* state, u32 screenshot_size = 256, u32 compression_method = 0,
|
|
|
|
bool ignore_media = false);
|
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
/// Runs the VM until the CPU execution is canceled.
|
|
|
|
void Execute();
|
|
|
|
|
|
|
|
/// Switches the GPU renderer by saving state, recreating the display window, and restoring state (if needed).
|
|
|
|
void RecreateSystem();
|
2020-07-22 16:35:23 +00:00
|
|
|
|
2020-07-31 07:09:18 +00:00
|
|
|
/// Recreates the GPU component, saving/loading the state so it is preserved. Call when the GPU renderer changes.
|
2023-08-27 12:48:40 +00:00
|
|
|
bool RecreateGPU(GPURenderer renderer, bool force_recreate_device = false, bool update_display = true);
|
2019-11-16 05:27:57 +00:00
|
|
|
|
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();
|
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
|
|
|
/// Updates the throttle period, call when target emulation speed changes.
|
|
|
|
void UpdateThrottlePeriod();
|
2020-12-06 16:43:46 +00:00
|
|
|
void ResetThrottler();
|
2020-01-24 04:53:40 +00:00
|
|
|
|
2020-07-31 07:09:18 +00:00
|
|
|
void UpdatePerformanceCounters();
|
|
|
|
void ResetPerformanceCounters();
|
2020-01-24 04:53:40 +00:00
|
|
|
|
2022-08-10 03:09:32 +00:00
|
|
|
/// Resets vsync/max present fps state.
|
|
|
|
void UpdateDisplaySync();
|
|
|
|
|
2020-07-31 07:09:18 +00:00
|
|
|
// Access controllers for simulating input.
|
|
|
|
Controller* GetController(u32 slot);
|
|
|
|
void UpdateControllers();
|
|
|
|
void UpdateControllerSettings();
|
|
|
|
void ResetControllers();
|
2021-05-24 09:55:07 +00:00
|
|
|
void UpdateMemoryCardTypes();
|
|
|
|
void UpdatePerGameMemoryCards();
|
2021-05-18 04:36:55 +00:00
|
|
|
bool HasMemoryCard(u32 slot);
|
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
|
|
|
|
2021-01-21 07:59:40 +00:00
|
|
|
void UpdateMultitaps();
|
2020-01-24 04:53:40 +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.
|
2021-03-26 16:19:23 +00:00
|
|
|
u32 GetMediaSubImageIndexForTitle(const 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
|
|
|
/// Checks for settings changes, std::move() the old settings away for comparing beforehand.
|
|
|
|
void CheckForSettingsChanges(const Settings& old_settings);
|
|
|
|
|
|
|
|
/// 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.
|
2022-10-05 08:29:08 +00:00
|
|
|
std::string GetGameSaveStateFileName(const 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
|
|
|
|
|
|
|
/// Returns intended output volume considering fast forwarding.
|
|
|
|
s32 GetAudioOutputVolume();
|
|
|
|
void UpdateVolume();
|
|
|
|
|
|
|
|
/// Returns true if currently dumping audio.
|
|
|
|
bool IsDumpingAudio();
|
|
|
|
|
|
|
|
/// Starts dumping audio to a file. If no file name is provided, one will be generated automatically.
|
|
|
|
bool StartDumpingAudio(const char* filename = nullptr);
|
|
|
|
|
|
|
|
/// Stops dumping audio to file if it has been started.
|
|
|
|
void StopDumpingAudio();
|
|
|
|
|
|
|
|
/// Saves a screenshot to the specified file. IF no file name is provided, one will be generated automatically.
|
|
|
|
bool SaveScreenshot(const char* filename = nullptr, bool full_resolution = true, bool apply_aspect_ratio = true,
|
|
|
|
bool compress_on_thread = true);
|
|
|
|
|
|
|
|
/// Loads the cheat list from the specified file.
|
|
|
|
bool LoadCheatList(const char* filename);
|
|
|
|
|
|
|
|
/// Loads the cheat list for the current game title from the user directory.
|
|
|
|
bool LoadCheatListFromGameTitle();
|
|
|
|
|
|
|
|
/// 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();
|
|
|
|
|
|
|
|
/// Saves the current cheat list to the specified file.
|
|
|
|
bool SaveCheatList(const char* filename);
|
|
|
|
|
|
|
|
/// 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.
|
|
|
|
void SetCheatCodeState(u32 index, bool enabled, bool save_to_file);
|
|
|
|
|
|
|
|
/// 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.
|
|
|
|
bool ShouldUseVSync();
|
|
|
|
|
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.
|
|
|
|
bool PresentDisplay(bool allow_skip_present);
|
|
|
|
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();
|
|
|
|
void UpdateMemorySaveStateSettings();
|
|
|
|
bool LoadRewindState(u32 skip_saves = 0, bool consume_state = true);
|
2021-01-23 16:52:52 +00:00
|
|
|
void SetRunaheadReplayFlag();
|
2021-01-23 09:00:54 +00:00
|
|
|
|
2023-09-17 02:28:11 +00:00
|
|
|
#ifdef ENABLE_DISCORD_PRESENCE
|
2023-09-07 10:13:48 +00:00
|
|
|
/// Called when rich presence changes.
|
2023-12-23 14:19:22 +00:00
|
|
|
void UpdateDiscordPresence(bool update_session_time);
|
2023-09-07 10:13:48 +00:00
|
|
|
#endif
|
|
|
|
|
2023-09-03 04:30:26 +00:00
|
|
|
namespace Internal {
|
2023-08-23 12:06:48 +00:00
|
|
|
/// Called on process startup.
|
|
|
|
void ProcessStartup();
|
|
|
|
|
|
|
|
/// Called on process shutdown.
|
|
|
|
void ProcessShutdown();
|
|
|
|
|
|
|
|
/// 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);
|
|
|
|
|
|
|
|
/// 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
|