summaryrefslogtreecommitdiff
path: root/soh/include/z64elf_message.h
blob: ed83bd048c1ebb04e3f6d11add5beff6dd56c73f (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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#ifndef Z64ELF_MESSAGE_H
#define Z64ELF_MESSAGE_H

#include <libultraship/libultra.h>

// Checks the condition and exits the script if the check passes
#define ELF_MSG_TYPE_CHECK  0
// ? (unused)
#define ELF_MSG_TYPE_UNK_1  1
// ? (unused)
#define ELF_MSG_TYPE_UNK_2  2
// Checks the condition and skips forward by some number of commands if the check passes
#define ELF_MSG_TYPE_SKIP   3
// Always ends the script, returning the text id for this command
#define ELF_MSG_TYPE_END    7

// Check an eventChkInf flag
#define ELF_MSG_CONDITION_FLAG          0
// Check a dungeon item (map, compass, boss key)
#define ELF_MSG_CONDITION_DUNGEON_ITEM  1
// Check if an item is in an item slot
#define ELF_MSG_CONDITION_ITEM          2
// "Other" conditions described below
#define ELF_MSG_CONDITION_OTHER         3

// Check what strength upgrade has been obtained so far
#define ELF_MSG_CONDITION_STRENGTH_UPG  0
// Check if specific boots have been obtained so far
#define ELF_MSG_CONDITION_BOOTS         1
// Check if a particular song has been obtained
#define ELF_MSG_CONDITION_SONG          2
// Check if a particular medallion has been obtained
#define ELF_MSG_CONDITION_MEDALLION     3
// Check if the magic meter has been obtained
#define ELF_MSG_CONDITION_MAGIC         4

/*
 * Bitpack byte 0
 */
#define ELF_MSG_B0(type, cond_type, tf)            \
    _SHIFTL(ELF_MSG_TYPE_##type, 5, 3) |           \
    _SHIFTL(ELF_MSG_CONDITION_##cond_type, 1, 4) | \
    _SHIFTL(tf, 0, 1)

/*
 * Bitpack byte 1
 */
#define ELF_MSG_B1(cond_type, data)                \
    _SHIFTL(ELF_MSG_CONDITION_##cond_type, 4, 4) | \
    _SHIFTL(data, 0, 4)

/*
 * Other bytes
 */
#define ELF_MSG_B(data) \
    _SHIFTL(data, 0, 8)

/*
 * Command macros
 */

#define ELF_MSG_FLAG(type, textId, tf, flag) \
    {                                        \
        ELF_MSG_B0(type, FLAG, tf),          \
        ELF_MSG_B(flag),                     \
        ELF_MSG_B(textId),                   \
        ELF_MSG_B(0),                        \
    }

#define ELF_MSG_END(textId)            \
    ELF_MSG_FLAG(END, textId, false, 0)

#define ELF_MSG_DUNGEON_ITEM(type, textId, tf, itemId) \
    {                                                  \
        ELF_MSG_B0(type, DUNGEON_ITEM, tf),            \
        ELF_MSG_B(itemId),                             \
        ELF_MSG_B(textId),                             \
        ELF_MSG_B(0),                                  \
    }

#define ELF_MSG_ITEM(type, textId, tf, slotItemId, itemId) \
    {                                                      \
        ELF_MSG_B0(type, ITEM, tf),                        \
        ELF_MSG_B(slotItemId),                             \
        ELF_MSG_B(textId),                                 \
        ELF_MSG_B(itemId),                                 \
    }

#define ELF_MSG_STRENGTH_UPG(type, textId, tf, strUpg) \
    {                                                  \
        ELF_MSG_B0(type, OTHER, tf),                   \
        ELF_MSG_B1(STRENGTH_UPG, strUpg),              \
        ELF_MSG_B(textId),                             \
        ELF_MSG_B(0),                                  \
    }

#define ELF_MSG_BOOTS(type, textId, tf, itemId) \
    {                                           \
        ELF_MSG_B0(type, OTHER, tf),            \
        ELF_MSG_B1(BOOTS, 0),                   \
        ELF_MSG_B(textId),                      \
        ELF_MSG_B(itemId),                      \
    }

#define ELF_MSG_SONG(type, textId, tf, itemId) \
    {                                           \
        ELF_MSG_B0(type, OTHER, tf),           \
        ELF_MSG_B1(SONG, 0),                   \
        ELF_MSG_B(textId),                     \
        ELF_MSG_B(itemId),                     \
    }

#define ELF_MSG_MEDALLION(type, textId, tf, itemId) \
    {                                               \
        ELF_MSG_B0(type, OTHER, tf),                \
        ELF_MSG_B1(MEDALLION, 0),                   \
        ELF_MSG_B(textId),                          \
        ELF_MSG_B(itemId),                          \
    }

#define ELF_MSG_MAGIC(type, textId, tf) \
    {                                   \
        ELF_MSG_B0(type, OTHER, tf),    \
        ELF_MSG_B1(MAGIC, 0),           \
        ELF_MSG_B(textId),              \
        ELF_MSG_B(0),                   \
    }

#endif