diff --git a/README.md b/README.md index 01e0c2a..eabf74c 100644 --- a/README.md +++ b/README.md @@ -6,3 +6,8 @@ library for writing user mode arm11 code for the 3DS (CTR) the goal with this is to create a very straightforward interface with the 3DS's OS. it is not meant to provide higher level functions; to put things in perspective, the purpose of ctrulib would be to sit between the OS and a possible port of SDL rather than replace it. + +license +======= + +you may do whatever the hell you want with ctrulib as long as you give proper credit to its authors. that includes making commercial games/apps that use ctrulib. i'd personally rather you didn't sell ctrulib itself, because that would not be nice of you, but i'm not a lawyer and it's not like i'm going to sue you. diff --git a/libctru/include/3ds/services/apt.h b/libctru/include/3ds/services/apt.h index 1a1e644..9377c0b 100644 --- a/libctru/include/3ds/services/apt.h +++ b/libctru/include/3ds/services/apt.h @@ -67,3 +67,5 @@ Result APT_ReplySleepQuery(Handle* handle, NS_APPID appID, u32 a); Result APT_ReplySleepNotificationComplete(Handle* handle, NS_APPID appID); Result APT_PrepareToCloseApplication(Handle* handle, u8 a); Result APT_CloseApplication(Handle* handle, u32 a, u32 b, u32 c); +Result APT_SetAppCpuTimeLimit(Handle* handle, u32 percent); +Result APT_GetAppCpuTimeLimit(Handle* handle, u32 *percent); diff --git a/libctru/source/services/apt.c b/libctru/source/services/apt.c index bda13b6..d2f65d9 100644 --- a/libctru/source/services/apt.c +++ b/libctru/source/services/apt.c @@ -743,3 +743,35 @@ Result APT_CloseApplication(Handle* handle, u32 a, u32 b, u32 c) return cmdbuf[1]; } + +//See http://3dbrew.org/APT:SetApplicationCpuTimeLimit +Result APT_SetAppCpuTimeLimit(Handle* handle, u32 percent) +{ + if(!handle)handle=&aptuHandle; + + u32* cmdbuf=getThreadCommandBuffer(); + cmdbuf[0]=0x4F0080; + cmdbuf[1]=1; + cmdbuf[2]=percent; + + Result ret=0; + if((ret=svcSendSyncRequest(*handle)))return ret; + + return cmdbuf[1]; +} + +Result APT_GetAppCpuTimeLimit(Handle* handle, u32 *percent) +{ + if(!handle)handle=&aptuHandle; + + u32* cmdbuf=getThreadCommandBuffer(); + cmdbuf[0]=0x500040; + cmdbuf[1]=1; + + Result ret=0; + if((ret=svcSendSyncRequest(*handle)))return ret; + + if(percent)*percent=cmdbuf[2]; + + return cmdbuf[1]; +}