summaryrefslogtreecommitdiff
path: root/src/map/battle.t.hpp
blob: b84d1f2d03589ba3d7cbd2e5d24fd40dc531d011 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#ifndef BATTLE_T_HPP
#define BATTLE_T_HPP

#include "../common/utils.hpp"

namespace e
{
enum class BF : uint16_t
{
    ZERO        = 0x0000,
    NEGATIVE_1  = 0xffff,

    WEAPON      = 0x0001,
#define BF_WEAPON BF::WEAPON
    MAGIC       = 0x0002,
#define BF_MAGIC BF::MAGIC
    MISC        = 0x0004,
#define BF_MISC BF::MISC
    SHORT       = 0x0010,
#define BF_SHORT BF::SHORT
    LONG        = 0x0040,
#define BF_LONG BF::LONG
    SKILL       = 0x0100,
#define BF_SKILL BF::SKILL
    NORMAL      = 0x0200,
#define BF_NORMAL BF::NORMAL
    WEAPONMASK  = 0x000f,
#define BF_WEAPONMASK BF::WEAPONMASK
    RANGEMASK   = 0x00f0,
#define BF_RANGEMASK BF::RANGEMASK
    SKILLMASK   = 0x0f00,
#define BF_SKILLMASK BF::SKILLMASK
};
ENUM_BITWISE_OPERATORS(BF)
}
using e::BF;

struct BCT
{
                        // former representation:
    uint8_t lo;         // 0x 00 00 00 ff
    uint8_t mid;        // 0x 00 00 ff 00
    uint8_t classic:4;  // 0x 00 0f 00 00
    uint8_t level:4;    // 0x 00 f0 00 00
    uint8_t unused;     // 0x ff 00 00 00

    operator bool() { return lo || mid || classic || level || unused; }
};

constexpr
BCT operator & (BCT l, BCT r) { return {uint8_t(l.lo & r.lo), uint8_t(l.mid & r.mid), uint8_t(l.classic & r.classic), uint8_t(l.level & r.level), uint8_t(l.unused & r.unused) }; }
constexpr
BCT operator | (BCT l, BCT r) { return {uint8_t(l.lo | r.lo), uint8_t(l.mid | r.mid), uint8_t(l.classic | r.classic), uint8_t(l.level | r.level), uint8_t(l.unused | r.unused) }; }
constexpr
BCT operator ^ (BCT l, BCT r) { return {uint8_t(l.lo ^ r.lo), uint8_t(l.mid ^ r.mid), uint8_t(l.classic ^ r.classic), uint8_t(l.level ^ r.level), uint8_t(l.unused ^ r.unused) }; }
inline
BCT& operator &= (BCT& l, BCT r) { return l = l & r; }
inline
BCT& operator |= (BCT& l, BCT r) { return l = l & r; }
inline
BCT& operator ^= (BCT& l, BCT r) { return l = l & r; }
// BCT operator ~(BCT r);

constexpr
bool operator == (BCT l, BCT r) { return l.lo == r.lo && l.mid == r.mid && l.classic == r.classic && l.level == r.level && l.unused == r.unused; }
constexpr
bool operator != (BCT l, BCT r) { return !(l == r); }

constexpr
BCT BCT_NOENEMY = {0x00, 0x00, 0x0, 0x0, 0x00};
constexpr
BCT BCT_ZERO = BCT_NOENEMY;
constexpr
BCT BCT_PARTY   = {0x00, 0x00, 0x1, 0x0, 0x00};
constexpr
BCT BCT_ENEMY   = {0x00, 0x00, 0x4, 0x0, 0x00};
constexpr
BCT BCT_NOPARTY = {0x00, 0x00, 0x5, 0x0, 0x00};
constexpr
BCT BCT_ALL     = {0x00, 0x00, 0x2, 0x0, 0x00};
constexpr
BCT BCT_NOONE   = {0x00, 0x00, 0x6, 0x0, 0x00};

constexpr
BCT BCT_lo_x01  = {0x01, 0x00, 0x0, 0x0, 0x00};
constexpr
BCT BCT_lo_x02  = {0x02, 0x00, 0x0, 0x0, 0x00};
constexpr
BCT BCT_mid_x05 = {0x00, 0x05, 0x0, 0x0, 0x00};
constexpr
BCT BCT_mid_x80 = {0x00, 0x80, 0x0, 0x0, 0x00};

constexpr
BCT BCT_highnib = {0x00, 0x00, 0x0, 0xf, 0x00};

#endif // BATTLE_T_HPP