Minor cleanup in os.h/os.c + add osGet3DSliderState()

This commit is contained in:
fincs 2015-11-05 12:33:43 +01:00
parent 2ce51cf3d8
commit b33b4eb2d0
2 changed files with 28 additions and 32 deletions

View File

@ -47,7 +47,10 @@ const char* osStrError(u32 error);
*
* This can be used to compare system versions easily with @ref SYSTEM_VERSION.
*/
u32 osGetFirmVersion(void);
static inline u32 osGetFirmVersion(void)
{
return (*(vu32*)0x1FF80060) & ~0xFF;
}
/**
* @brief Gets the system's kernel version.
@ -59,7 +62,10 @@ u32 osGetFirmVersion(void);
* if(osGetKernelVersion() > SYSTEM_VERSION(2,46,0)) printf("You are running 9.0 or higher\n");
* @endcode
*/
u32 osGetKernelVersion(void);
static inline u32 osGetKernelVersion(void)
{
return (*(vu32*)0x1FF80000) & ~0xFF;
}
/**
* @brief Gets the current time.
@ -82,7 +88,19 @@ u64 osGetTime(void);
*
* These values correspond with the number of wifi bars displayed by Home Menu.
*/
u8 osGetWifiStrength(void);
static inline u8 osGetWifiStrength(void)
{
return *(vu8*)0x1FF81066;
}
/**
* @brief Gets the state of the 3D slider.
* @return The state of the 3D slider (0.0~1.0)
*/
static inline float osGet3DSliderState(void)
{
return *(volatile float*)0x1FF81080;
}
/**
* @brief Configures the New 3DS speedup.

View File

@ -20,12 +20,9 @@ typedef struct {
//...
} datetime_t;
static volatile u32* __datetime_selector =
(u32*) 0x1FF81000;
static volatile datetime_t* __datetime0 =
(datetime_t*) 0x1FF81020;
static volatile datetime_t* __datetime1 =
(datetime_t*) 0x1FF81040;
#define __datetime_selector (*(vu32*)0x1FF81000)
#define __datetime0 (*(volatile datetime_t*)0x1FF81020)
#define __datetime1 (*(volatile datetime_t*)0x1FF81040)
__attribute__((weak)) bool __ctru_speedup = false;
@ -54,16 +51,16 @@ u32 osConvertOldLINEARMemToNew(u32 vaddr) {
//---------------------------------------------------------------------------------
static datetime_t getSysTime(void) {
//---------------------------------------------------------------------------------
u32 s1, s2 = *__datetime_selector & 1;
u32 s1, s2 = __datetime_selector & 1;
datetime_t dt;
do {
s1 = s2;
if(!s1)
dt = *__datetime0;
dt = __datetime0;
else
dt = *__datetime1;
s2 = *__datetime_selector & 1;
dt = __datetime1;
s2 = __datetime_selector & 1;
} while(s2 != s1);
return dt;
@ -97,7 +94,6 @@ int __libctru_gtod(struct _reent *ptr, struct timeval *tp, struct timezone *tz)
}
// Returns number of milliseconds since 1st Jan 1900 00:00.
//---------------------------------------------------------------------------------
u64 osGetTime(void) {
@ -109,18 +105,6 @@ u64 osGetTime(void) {
return dt.date_time + (u32)(u64_to_double(delta)/TICKS_PER_MSEC);
}
//---------------------------------------------------------------------------------
u32 osGetFirmVersion(void) {
//---------------------------------------------------------------------------------
return (*(u32*)0x1FF80060) & ~0xFF;
}
//---------------------------------------------------------------------------------
u32 osGetKernelVersion(void) {
//---------------------------------------------------------------------------------
return (*(u32*)0x1FF80000) & ~0xFF;
}
//---------------------------------------------------------------------------------
const char* osStrError(u32 error) {
//---------------------------------------------------------------------------------
@ -152,12 +136,6 @@ const char* osStrError(u32 error) {
}
}
//---------------------------------------------------------------------------------
u8 osGetWifiStrength(void) {
//---------------------------------------------------------------------------------
return *((u8*)0x1FF81066);
}
void __ctru_speedup_config(void)
{
if (ptmSysmInit()==0)