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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
|
//
// Generated by dtk
// Translation Unit: d_a_andsw2.cpp
//
#include "d/actor/d_a_andsw2.h"
#include "f_op/f_op_actor_mng.h"
#include "JSystem/JKernel/JKRHeap.h"
#include "d/d_com_inf_game.h"
#include "d/d_procname.h"
#include "dolphin/types.h"
enum Action {
ACT_ON_ALL,
ACT_TIMER,
ACT_ORDER,
ACT_EVENT,
ACT_OFF,
ACT_WAIT,
};
enum Type {
TYPE_ONE_OFF,
TYPE_CONTINUOUS,
};
/* 00000078-00000084 .text getEventNo__10daAndsw2_cFv */
u8 daAndsw2_c::getEventNo() {
return (orig.angle.x & 0x00FF) >> 0;
}
/* 00000084-00000090 .text getSwbit__10daAndsw2_cFv */
u8 daAndsw2_c::getSwbit() {
// Switch to set.
return (mBase.mParameters & 0x00FF0000) >> 16;
}
/* 00000090-0000009C .text getSwbit2__10daAndsw2_cFv */
u8 daAndsw2_c::getSwbit2() {
// First switch to check.
return (mBase.mParameters & 0xFF000000) >> 24;
}
/* 0000009C-000000A8 .text getType__10daAndsw2_cFv */
u8 daAndsw2_c::getType() {
return (mBase.mParameters & 0x0000FF00) >> 8;
}
/* 000000A8-000000B4 .text getTimer__10daAndsw2_cFv */
u8 daAndsw2_c::getTimer() {
return (orig.angle.z & 0x00FF) >> 0;
}
/* 000000B4-000000C0 .text getNum__10daAndsw2_cFv */
u8 daAndsw2_c::getNum() {
// Number of switches to check.
return (mBase.mParameters & 0x000000FF) >> 0;
}
/* 000000C0-00000130 .text getTopSw__10daAndsw2_cFv */
u8 daAndsw2_c::getTopSw() {
// Swbit2 is the first switch to check.
// If unspecified, start checking from the next switch after the switch to set (Swbit) instead.
if (getSwbit2() != 0xFF) {
return getSwbit2();
}
if (getSwbit() != 0xFF) {
return getSwbit() + 1;
}
return 0xFF;
}
/* 00000130-000001D8 .text chkAllSw2__10daAndsw2_cFv */
BOOL daAndsw2_c::chkAllSw2() {
int topSw = getTopSw();
int num = getNum();
if (num == 0xFF || num == 0 || topSw == 0xFF) {
return false;
}
for (int i = 0; i < num; i++) {
if (!dComIfGs_isSwitch(topSw+i, current.roomNo)) {
return false;
}
}
return TRUE;
}
/* 000001D8-000002B0 .text daAndsw2_actionOnAll__FP10daAndsw2_c */
static BOOL daAndsw2_actionOnAll(daAndsw2_c* i_this) {
if (i_this->chkAllSw2()) {
if (i_this->getTimer() != 0xFF) {
i_this->mTimer = i_this->getTimer()*15;
i_this->setActio(ACT_TIMER);
} else if (i_this->mEventIdx != -1) {
i_this->setActio(ACT_ORDER);
} else {
int room = i_this->current.roomNo;
int sw = i_this->getSwbit();
dComIfGs_onSwitch(sw, room);
if (i_this->getType() == TYPE_CONTINUOUS) {
i_this->setActio(ACT_OFF);
} else {
i_this->setActio(ACT_WAIT);
}
}
}
return TRUE;
}
/* 000002B0-00000380 .text daAndsw2_actionTimer__FP10daAndsw2_c */
static BOOL daAndsw2_actionTimer(daAndsw2_c* i_this) {
if (i_this->getType() == TYPE_CONTINUOUS && !i_this->chkAllSw2()) {
i_this->setActio(ACT_ON_ALL);
} else if (i_this->mTimer > 0) {
i_this->mTimer -= 1;
} else if (i_this->mEventIdx != -1) {
i_this->setActio(ACT_ORDER);
} else {
int room = i_this->current.roomNo;
int sw = i_this->getSwbit();
dComIfGs_onSwitch(sw, room);
if (i_this->getType() == TYPE_CONTINUOUS) {
i_this->setActio(ACT_WAIT);
}
}
return TRUE;
}
/* 00000380-00000438 .text daAndsw2_actionOrder__FP10daAndsw2_c */
static BOOL daAndsw2_actionOrder(daAndsw2_c* i_this) {
if (i_this->mEvtInfo.checkCommandDemoAccrpt()) {
i_this->setActio(ACT_EVENT);
int room = i_this->current.roomNo;
int sw = i_this->getSwbit();
dComIfGs_onSwitch(sw, room);
} else if (i_this->getType() == TYPE_CONTINUOUS && !i_this->chkAllSw2()) {
i_this->setActio(ACT_ON_ALL);
} else {
fopAcM_orderOtherEventId(i_this, i_this->mEventIdx, i_this->getEventNo());
}
return TRUE;
}
/* 00000438-000004BC .text daAndsw2_actionEvent__FP10daAndsw2_c */
static BOOL daAndsw2_actionEvent(daAndsw2_c* i_this) {
if (dComIfGp_evmng_endCheck(i_this->mEventIdx)) {
if (i_this->getType() == TYPE_CONTINUOUS) {
i_this->setActio(ACT_OFF);
} else {
i_this->setActio(ACT_WAIT);
}
dComIfGp_event_reset();
}
return TRUE;
}
/* 000004BC-00000528 .text daAndsw2_actionOff__FP10daAndsw2_c */
static BOOL daAndsw2_actionOff(daAndsw2_c* i_this) {
if (!i_this->chkAllSw2()) {
i_this->setActio(ACT_ON_ALL);
int room = i_this->current.roomNo;
int sw = i_this->getSwbit();
dComIfGs_offSwitch(sw, room);
}
return TRUE;
}
/* 00000528-00000530 .text daAndsw2_actionWait__FP10daAndsw2_c */
static BOOL daAndsw2_actionWait(daAndsw2_c* i_this) {
return TRUE;
}
BOOL daAndsw2_c::execute() {
static BOOL (*l_action[6])(daAndsw2_c*) = {
daAndsw2_actionOnAll,
daAndsw2_actionTimer,
daAndsw2_actionOrder,
daAndsw2_actionEvent,
daAndsw2_actionOff,
daAndsw2_actionWait,
};
l_action[mAction](this);
return TRUE;
}
s32 daAndsw2_c::create() {
int sw = getSwbit();
fopAcM_SetupActor(this, daAndsw2_c);
switch (getType()) {
case TYPE_ONE_OFF:
if (sw == 0xFF || dComIfGs_isSwitch(sw, current.roomNo)) {
// Switch invalid or already set.
setActio(ACT_WAIT);
} else {
// Switch not yet set, check for the condition to be met.
setActio(ACT_ON_ALL);
}
mEventIdx = dComIfGp_evmng_getEventIdx(NULL, getEventNo());
break;
case TYPE_CONTINUOUS:
if (sw == 0xFF) {
// Switch invalid.
setActio(ACT_WAIT);
} else if (dComIfGs_isSwitch(sw, current.roomNo)) {
// Switch already set, wait for the condition to no longer be met.
setActio(ACT_OFF);
} else {
// Switch not yet set, check for the condition to be met.
setActio(ACT_ON_ALL);
}
mEventIdx = dComIfGp_evmng_getEventIdx(NULL, getEventNo());
break;
default:
// Invalid type, do nothing.
setActio(ACT_WAIT);
break;
}
// Clear the parameters out of the current rotation.
shape_angle.z = 0;
shape_angle.x = 0;
current.angle.z = 0;
current.angle.x = 0;
return cPhs_COMPLEATE_e;
}
/* 00000530-00000538 .text daAndsw2_Draw__FP10daAndsw2_c */
static BOOL daAndsw2_Draw(daAndsw2_c* i_this) {
return TRUE;
}
/* 00000538-00000574 .text daAndsw2_Execute__FP10daAndsw2_c */
static BOOL daAndsw2_Execute(daAndsw2_c* i_this) {
return i_this->execute();
}
/* 00000574-0000057C .text daAndsw2_IsDelete__FP10daAndsw2_c */
static BOOL daAndsw2_IsDelete(daAndsw2_c* i_this) {
return TRUE;
}
/* 0000057C-000005AC .text daAndsw2_Delete__FP10daAndsw2_c */
static BOOL daAndsw2_Delete(daAndsw2_c* i_this) {
i_this->~daAndsw2_c();
return TRUE;
}
/* 000005AC-00000724 .text daAndsw2_Create__FP10fopAc_ac_c */
static s32 daAndsw2_Create(fopAc_ac_c* ac) {
return ((daAndsw2_c*)ac)->create();
}
static actor_method_class l_daAndsw2_Method = {
(process_method_func)daAndsw2_Create,
(process_method_func)daAndsw2_Delete,
(process_method_func)daAndsw2_Execute,
(process_method_func)daAndsw2_IsDelete,
(process_method_func)daAndsw2_Draw,
};
actor_process_profile_definition g_profile_ANDSW2 = {
/* LayerID */ fpcLy_CURRENT_e,
/* ListID */ 7,
/* ListPrio */ fpcPi_CURRENT_e,
/* ProcName */ PROC_ANDSW2,
/* Proc SubMtd */ &g_fpcLf_Method.mBase,
/* Size */ sizeof(daAndsw2_c),
/* SizeOther */ 0,
/* Parameters */ 0,
/* Leaf SubMtd */ &g_fopAc_Method.base,
/* Priority */ 0x0136,
/* Actor SubMtd */ &l_daAndsw2_Method,
/* Status */ fopAcStts_UNK4000_e | fopAcStts_UNK40000_e,
/* Group */ fopAc_ACTOR_e,
/* CullType */ fopAc_CULLBOX_6_e,
};
|