Skip to content

Commit

Permalink
Add svcs to get and set the emulation speed. (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloMK7 authored Apr 6, 2024
1 parent 775ceac commit 0c2f076
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/core/hle/kernel/svc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "common/logging/log.h"
#include "common/microprofile.h"
#include "common/scm_rev.h"
#include "common/settings.h"
#include "core/arm/arm_interface.h"
#include "core/core.h"
#include "core/core_timing.h"
Expand Down Expand Up @@ -74,6 +75,12 @@ enum class KernelState {
* Reboots the console
*/
KERNEL_STATE_REBOOT = 7,

// Special Citra only states.
/**
* Sets the emulation speed percentage. A value of 0 means unthrottled.
*/
KERNEL_STATE_CITRA_EMULATION_SPEED = 0x20000 ///
};

struct PageInfo {
Expand Down Expand Up @@ -270,6 +277,7 @@ enum class SystemInfoMemUsageRegion {
enum class SystemInfoCitraInformation {
IS_CITRA = 0, // Always set the output to 1, signaling the app is running on Citra.
HOST_TICK = 1, // Tick reference from the host in ns, unaffected by lag or cpu speed.
EMULATION_SPEED = 2, // Gets the emulation speed set by the user or by KernelSetState.
BUILD_NAME = 10, // (ie: Nightly, Canary).
BUILD_VERSION = 11, // Build version.
BUILD_PLATFORM = 12, // Build platform, see SystemInfoCitraPlatform.
Expand Down Expand Up @@ -1420,6 +1428,12 @@ Result SVC::KernelSetState(u32 kernel_state, u32 varg1, u32 varg2) {
case KernelState::KERNEL_STATE_REBOOT:
system.RequestShutdown();
break;

// Citra specific states.
case KernelState::KERNEL_STATE_CITRA_EMULATION_SPEED: {
u16 new_value = static_cast<u16>(varg1);
Settings::values.frame_limit.SetValue(new_value);
} break;
default:
LOG_ERROR(Kernel_SVC, "Unknown KernelSetState state={} varg1={} varg2={}", kernel_state,
varg1, varg2);
Expand Down Expand Up @@ -1795,6 +1809,9 @@ Result SVC::GetSystemInfo(s64* out, u32 type, s32 param) {
std::chrono::steady_clock::now().time_since_epoch())
.count());
break;
case SystemInfoCitraInformation::EMULATION_SPEED:
*out = static_cast<s64>(Settings::values.frame_limit.GetValue());
break;
case SystemInfoCitraInformation::BUILD_NAME:
CopyStringPart(reinterpret_cast<char*>(out), Common::g_build_name, 0, sizeof(s64));
break;
Expand Down

0 comments on commit 0c2f076

Please sign in to comment.