Add code to manage New 3DS CPU speedup
# Conflicts: # libctru/include/3ds/os.h # libctru/include/3ds/services/ptm.h
This commit is contained in:
parent
b9e5ddb944
commit
e12c8ff6a6
@ -73,3 +73,9 @@ u64 osGetTime();
|
||||
* @return the Wifi signal strength
|
||||
*/
|
||||
u8 osGetWifiStrength();
|
||||
|
||||
/**
|
||||
* @brief Configures the New 3DS speedup.
|
||||
* @param enable Specifies whether to enable or disable the speedup.
|
||||
*/
|
||||
void osSetSpeedupEnable(bool enable);
|
||||
|
@ -3,8 +3,13 @@
|
||||
Result ptmInit();
|
||||
Result ptmExit();
|
||||
|
||||
Result ptmSysmInit(void);
|
||||
Result ptmSysmExit(void);
|
||||
|
||||
Result PTMU_GetShellState(Handle* servhandle, u8 *out);
|
||||
Result PTMU_GetBatteryLevel(Handle* servhandle, u8 *out);
|
||||
Result PTMU_GetBatteryChargeState(Handle* servhandle, u8 *out);
|
||||
Result PTMU_GetPedometerState(Handle* servhandle, u8 *out);
|
||||
Result PTMU_GetTotalStepCount(Handle* servhandle, u32 *steps);
|
||||
|
||||
Result PTMSYSM_ConfigureNew3DSCPU(u8 value);
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include <3ds/types.h>
|
||||
#include <3ds/os.h>
|
||||
#include <3ds/svc.h>
|
||||
#include <3ds/services/ptm.h>
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <reent.h>
|
||||
@ -26,6 +27,7 @@ static volatile datetime_t* __datetime0 =
|
||||
static volatile datetime_t* __datetime1 =
|
||||
(datetime_t*) 0x1FF81040;
|
||||
|
||||
__attribute__((weak)) bool __ctru_speedup = false;
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
u32 osConvertVirtToPhys(u32 vaddr) {
|
||||
@ -155,3 +157,18 @@ u8 osGetWifiStrength(void) {
|
||||
//---------------------------------------------------------------------------------
|
||||
return *((u8*)0x1FF81066);
|
||||
}
|
||||
|
||||
void __ctru_speedup_config(void)
|
||||
{
|
||||
if (ptmSysmInit()==0)
|
||||
{
|
||||
PTMSYSM_ConfigureNew3DSCPU(__ctru_speedup ? 3 : 0);
|
||||
ptmSysmExit();
|
||||
}
|
||||
}
|
||||
|
||||
void osSetSpeedupEnable(bool enable)
|
||||
{
|
||||
__ctru_speedup = enable;
|
||||
__ctru_speedup_config();
|
||||
}
|
||||
|
@ -62,6 +62,8 @@ __attribute__((weak)) void _aptDebug(int a, int b)
|
||||
{
|
||||
}
|
||||
|
||||
void __ctru_speedup_config(void);
|
||||
|
||||
static void aptAppStarted(void);
|
||||
|
||||
static bool aptIsReinit(void)
|
||||
@ -395,7 +397,7 @@ static bool __handle_incoming_parameter() {
|
||||
aptSetStatus(APP_APPLETCLOSED);
|
||||
return true;
|
||||
case 0xB: // Just returned from menu.
|
||||
if (aptStatusMutex)
|
||||
if (aptGetStatus() != APP_NOTINITIALIZED)
|
||||
{
|
||||
GSPGPU_AcquireRight(NULL, 0x0);
|
||||
GSPGPU_RestoreVramSysArea(NULL);
|
||||
@ -462,6 +464,8 @@ Result aptInit(void)
|
||||
|
||||
svcCreateEvent(&aptStatusEvent, 0);
|
||||
svcCreateEvent(&aptSleepSync, 0);
|
||||
svcCreateMutex(&aptStatusMutex, false);
|
||||
aptStatus=0;
|
||||
|
||||
if(!aptIsCrippled())
|
||||
{
|
||||
@ -626,10 +630,6 @@ void aptAppStarted()
|
||||
{
|
||||
u8 buf1[4], buf2[4];
|
||||
|
||||
svcCreateMutex(&aptStatusMutex, true);
|
||||
aptStatus=0;
|
||||
svcReleaseMutex(aptStatusMutex);
|
||||
|
||||
aptSetStatus(APP_RUNNING);
|
||||
|
||||
if(!aptIsCrippled())
|
||||
@ -669,6 +669,8 @@ void aptSetStatus(APP_STATUS status)
|
||||
|
||||
//if(prevstatus != APP_NOTINITIALIZED)
|
||||
//{
|
||||
if(status == APP_RUNNING)
|
||||
__ctru_speedup_config();
|
||||
if(status == APP_RUNNING || status == APP_EXITING || status == APP_APPLETSTARTED || status == APP_APPLETCLOSED)
|
||||
svcSignalEvent(aptStatusEvent);
|
||||
//}
|
||||
|
@ -5,11 +5,11 @@
|
||||
#include <3ds/services/ptm.h>
|
||||
|
||||
|
||||
static Handle ptmHandle;
|
||||
static Handle ptmHandle, ptmSysmHandle;
|
||||
|
||||
Result ptmInit()
|
||||
{
|
||||
return srvGetServiceHandle(&ptmHandle, "ptm:u");
|
||||
return srvGetServiceHandle(&ptmHandle, "ptm:u");
|
||||
}
|
||||
|
||||
Result ptmExit()
|
||||
@ -17,6 +17,16 @@ Result ptmExit()
|
||||
return svcCloseHandle(ptmHandle);
|
||||
}
|
||||
|
||||
Result ptmSysmInit(void)
|
||||
{
|
||||
return srvGetServiceHandle(&ptmSysmHandle, "ptm:sysm");
|
||||
}
|
||||
|
||||
Result ptmSysmExit(void)
|
||||
{
|
||||
return svcCloseHandle(ptmSysmHandle);
|
||||
}
|
||||
|
||||
Result PTMU_GetShellState(Handle* servhandle, u8 *out)
|
||||
{
|
||||
if(!servhandle)servhandle=&ptmHandle;
|
||||
@ -91,3 +101,16 @@ Result PTMU_GetTotalStepCount(Handle* servhandle, u32 *steps)
|
||||
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
|
||||
Result PTMSYSM_ConfigureNew3DSCPU(u8 value)
|
||||
{
|
||||
Result ret;
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
|
||||
cmdbuf[0] = 0x08180040;
|
||||
cmdbuf[1] = value;
|
||||
|
||||
if((ret = svcSendSyncRequest(ptmSysmHandle))!=0)return ret;
|
||||
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user