Files
tp/include/JSystem/JSupport/JSupport.h
T

47 lines
861 B
C++
Raw Normal View History

2022-01-12 19:14:44 +01:00
#ifndef JSUPPORT_H
#define JSUPPORT_H
2024-10-10 07:29:58 -07:00
#include <dolphin.h>
2025-09-04 07:56:59 -07:00
#include <stdint.h>
2024-10-10 07:29:58 -07:00
2024-04-12 00:10:30 -06:00
/**
* @ingroup jsystem-jsupport
*
*/
template <typename T>
2025-09-04 07:56:59 -07:00
T* JSUConvertOffsetToPtr(const void* ptr, uintptr_t offset) {
if (offset == 0) {
return NULL;
} else {
2025-09-04 07:56:59 -07:00
return (T*)((intptr_t)ptr + (intptr_t)offset);
}
}
2023-02-26 17:50:56 -08:00
2024-04-12 00:10:30 -06:00
/**
* @ingroup jsystem-jsupport
*
*/
2022-01-12 19:14:44 +01:00
template <typename T>
T* JSUConvertOffsetToPtr(const void* ptr, const void* offset) {
2022-10-04 17:29:53 -07:00
if (offset == NULL) {
2022-01-12 19:14:44 +01:00
return NULL;
} else {
2025-09-04 07:56:59 -07:00
return (T*)((intptr_t)ptr + (intptr_t)offset);
2022-01-12 19:14:44 +01:00
}
}
inline u8 JSULoNibble(u8 param_0) { return param_0 & 0x0f; }
inline u8 JSUHiNibble(u8 param_0) {return param_0 >> 4; }
2023-02-26 17:50:56 -08:00
inline u8 JSULoByte(u16 in) {
return in & 0xff;
}
inline u8 JSUHiByte(u16 in) {
return in >> 8;
}
inline u16 JSULoHalf(u32 param_0) {return param_0; }
2022-01-12 19:14:44 +01:00
#endif