summaryrefslogtreecommitdiff
path: root/include/JSystem/JSupport/JSupport.h
blob: ef2fffcfe51c92c525941149e426f0381688e838 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef JSUPPORT_H
#define JSUPPORT_H

#include "common.h"

/**
* @ingroup jsystem-jsupport
* 
*/
template <typename T>
T* JSUConvertOffsetToPtr(const void* ptr, u32 offset) {
    if (offset == 0) {
        return NULL;
    } else {
        return (T*)((s32)ptr + (s32)offset);
    }
}

/**
* @ingroup jsystem-jsupport
* 
*/
template <typename T>
T* JSUConvertOffsetToPtr(const void* ptr, const void* offset) {
    if (offset == NULL) {
        return NULL;
    } else {
        return (T*)((s32)ptr + (s32)offset);
    }
}

inline u8 JSULoNibble(u8 param_0) { return param_0 & 0x0f; }
inline u8 JSUHiNibble(u8 param_0) {return param_0 >> 4; }

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; }

#endif