Lodestone.Common
Loading...
Searching...
No Matches
Indexing.h
Go to the documentation of this file.
1//
2// Created by DexrnZacAttack on 10/14/25 using zPc-i2.
3//
4#ifndef LODESTONE_INDEXING_H
5#define LODESTONE_INDEXING_H
6
8
9namespace lodestone::common {
10
11#define INDEX_ZYX(x, y, z, w, h) (z * h * x) + (y * x) + x
12#define INDEX_YZX(x, y, z, w, d) (y * d + z) * w + x
13#define INDEX_XZY(x, y, z, h, d) (x * d + z) * h + y
14#define INDEX_YX(x, y, w) y *w + x
15#define INDEX_XY(x, y, h) x *h + y
16
17// https://stackoverflow.com/a/34165114
18#define GET_NIBBLE(ary, idx) \
19 (idx % 2 ? /* if odd */ ary[idx / 2] & 0xf0 >> 4 \
20 : /* if even */ ary[idx / 2] & 0x0f)
21#define SET_NIBBLE(ary, idx, val) \
22 (idx % 2 ? ary[idx / 2] = (ary[idx / 2] & 0x0f) | ((val & 0x0f) << 4) \
23 : ary[idx / 2] = (ary[idx / 2] & 0xf0) | (val & 0x0f))
24
25} // namespace lodestone::common
26
27#endif // LODESTONE_INDEXING_H
Definition DataBuffer.cpp:6