summaryrefslogtreecommitdiff
path: root/arm9/source/bang.h
blob: 1e13f9fb59576953a8e7a3ad496b3443b4274581 (plain) (blame)
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
#ifndef BANG_H_
    #define BANG_H_

    #define SET_HIGH(v,high)  v = high << 8 | (v & 0x00ff)
    #define SET_LOW(v,low)    v = (v & 0xff00) | low
    #define HIGH(v)           (u8)((v) >> 8)
    #define LOW(v)            (u8)((v)     )

    #define H_HIGH(v)         (u8)((v) >> 24)
    #define H_LOW(v)          (u8)((v) >> 16)
    #define L_HIGH(v)         (u8)((v) >>  8)
    #define L_LOW(v)          (u8)((v)      )

    #define LEFT(x)       ((x) >> 4)
    #define RIGHT(x)      ((x) & 0xf)

    #define SHF(x,y)      (x >> RIGHT(y) << LEFT(y))
    #define TAL(x)        __builtin_popcount(x)

    #define TEST(x,m)     ((x & m) == m)
    #define BOOL(v)       ((u8)-(v))
    #define DOUBLE(h,l)   ((u16)(h) << 8 | (u16)(l))

    u8 rev(u8 x);
    u8 shc(u8 x, u8 y);
    u16 shcd(u16 x, u8 y);
#endif