summaryrefslogtreecommitdiff
path: root/include/JSystem/JSupport/JSupport.h
blob: 6d9a0c1df4435f2db9c83e7bcb07545b6a257a1e (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
#ifndef JSUPPORT_H
#define JSUPPORT_H

template <typename T>
T* JSUConvertOffsetToPtr(const void* ptr, u32 offset) {
    if (offset == NULL) {
        return NULL;
    } else {
        return (T*)((s32)ptr + offset);
    }
}

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 & 0xff) >> 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