Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
player_turn.c
Go to the documentation of this file.
1/* FIGHTSTG's player turn: the command menu and the menus it opens, until the
2 turn's action is picked. */
3
5
6/* Opens the command menu with the HUD, the partner view and the shot camera,
7 then goes to the menu of the command picked */
8static inline void runCommandMenu(PlayerTurn *task, PlayerTurnChild *children) {
9 switch (task->counter) {
10 case 0:
11 default:
12 if (children[0].task == NULL) {
13 children[0].hud = FIGHTSTG_createHud();
14 }
15 if (children[1].task == NULL) {
16 children[1].commandMenu = FIGHTSTG_createCommandMenu(task->command, &task->result);
17 }
18 if (children[2].task == NULL) {
20 }
21 if (children[6].task == NULL) {
23 }
24 task->result = -1;
25 task->tickCounter(task);
26 /* fallthrough */
27 case 1:
28 if (task->result != -1) {
29 task->command = task->result;
30 switch (task->result) {
32 task->action = 0;
33 task->setSubstate(task, 0);
34 break;
36 task->setStep(task, 3);
37 break;
39 task->setStep(task, 1);
40 break;
42 task->setStep(task, 4);
43 task->switchLine = 0;
44 break;
46 task->setStep(task, 2);
47 break;
49 task->action = 1;
50 task->setSubstate(task, 0);
51 break;
52 }
53 }
54 break;
55 }
56}
57
58/* Opens the digivolve menu for the active partner and, once a Digimon is
59 picked, makes digivolving the action */
60static inline void runDigivolveMenu(PlayerTurn *task, PlayerTurnChild *children) {
61 switch (task->counter) {
62 case 0:
63 default:
66 task->tickCounter(task);
67 /* fallthrough */
68 case 1:
69 switch (task->result) {
70 case -1:
71 break;
72 case -2:
73 task->setSubstate(task, 2);
74 break;
75 default:
76 task->action = 2;
78 task->digimon = task->result;
79 task->setSubstate(task, 0);
80 break;
81 }
82 break;
83 }
84}
85
86/* Opens the item menu and, once an item is picked, makes using it the
87 action */
88static inline void runItemMenu(PlayerTurn *task, PlayerTurnChild *children) {
89 switch (task->counter) {
90 case 0:
91 default:
92 children[3].itemMenu = FIGHTSTG_createItemMenu(&task->result);
93 task->tickCounter(task);
94 /* fallthrough */
95 case 1:
96 switch (task->result) {
97 case -1:
98 break;
99 case -2:
100 task->setSubstate(task, 2);
101 break;
102 default:
103 task->action = 3;
104 task->arg = task->result;
105 task->setSubstate(task, 0);
106 break;
107 }
108 break;
109 }
110}
111
112/* Opens the technique menu and, once a technique is picked, makes using it
113 the action */
114static inline void runTechMenu(PlayerTurn *task, PlayerTurnChild *children) {
115 switch (task->counter) {
116 case 0:
117 default:
118 children[3].techMenu = FIGHTSTG_createTechMenu(&task->result);
119 task->tickCounter(task);
120 /* fallthrough */
121 case 1:
122 switch (task->result) {
123 case -1:
124 break;
125 case -2:
126 task->setSubstate(task, 2);
127 break;
128 default:
129 task->action = 4;
130 task->arg = task->result;
131 task->setSubstate(task, 0);
132 break;
133 }
134 break;
135 }
136}
137
138/* Opens the switch menu and then the switch-in menu with the pair technique
139 for the Digimon picked, and makes the switch the action */
140static inline void runSwitchMenu(PlayerTurn *task, PlayerTurnChild *children) {
141 switch (task->counter) {
142 case 0:
143 default:
144 children[3].switchMenu = FIGHTSTG_createSwitchMenu(&task->result, &task->switchLine, 1);
145 task->tickCounter(task);
146 /* fallthrough */
147 case 1:
148 switch (task->result) {
149 case -1:
150 break;
151 case -2:
152 task->setSubstate(task, 2);
153 break;
154 default:
155 task->arg = task->result;
156 children[4].switchInMenu = FIGHTSTG_createPairSwitchMenu(&task->result, &task->pairTech);
157 task->tickCounter(task);
158 break;
159 }
160 break;
161 case 2:
162 switch (task->result) {
163 case -1:
164 break;
165 case -2:
166 task->setCounter(task, 0);
167 break;
168 default:
169 if ((task->result & 0xF) == 0) {
170 task->action = 5;
171 task->digimon = task->result >> 4;
172 task->setSubstate(task, 0);
173 task->switchLine = 0;
174 } else {
175 task->action = 6;
176 task->digimon = task->result >> 4;
177 task->setSubstate(task, 0);
178 task->switchLine = 0;
179 }
180 break;
181 }
182 break;
183 }
184}
185
186/* Opens the confused menu with the partner view and the shot camera, and
187 makes its pick the action */
188static inline void runConfusedMenu(PlayerTurn *task, PlayerTurnChild *children) {
189 switch (task->counter) {
190 case 0:
191 default:
192 if (children[2].task == NULL) {
194 }
195 if (children[6].task == NULL) {
197 }
198 if (children[1].task == NULL) {
199 children[1].confusedMenu = FIGHTSTG_createConfusedMenu(&task->result, children[2].task, children[6].task);
200 }
201 task->result = -1;
202 task->tickCounter(task);
203 /* fallthrough */
204 case 1:
205 switch (task->result) {
206 case -1:
207 break;
208 case 0:
209 task->action = 0;
210 task->setSubstate(task, 0);
211 break;
212 default:
213 task->action = -1;
214 task->setSubstate(task, 0);
215 break;
216 }
217 break;
218 }
219}
220
221/* Opens the switch menu after a knockout and then the switch-in menu, and
222 makes the switch the action */
223static inline void runKnockOutSwitchMenu(PlayerTurn *task, PlayerTurnChild *children) {
224 switch (task->counter) {
225 case 0:
226 default:
227 if (children[6].task == NULL) {
229 }
230 if (children[3].task == NULL) {
231 children[3].switchMenu = FIGHTSTG_createSwitchMenu(&task->result, &task->switchLine, 0);
232 }
233 task->tickCounter(task);
234 /* fallthrough */
235 case 1:
236 if (task->result != -1) {
237 task->arg = task->result;
238 children[4].switchInMenu = FIGHTSTG_createSwitchInMenu(&task->result);
239 task->tickCounter(task);
240 }
241 break;
242 case 2:
243 switch (task->result) {
244 case -1:
245 break;
246 case -2:
247 task->setCounter(task, 0);
248 break;
249 default:
250 if ((task->result & 0xF) == 0) {
251 task->action = 5;
252 task->digimon = task->result >> 4;
253 task->setSubstate(task, 0);
254 task->switchLine = 0;
255 }
256 break;
257 }
258 break;
259 }
260}
261
262/* The player's turn: substate 2 opens the command menu (runCommandMenu)
263 and then the menu of its command (runDigivolveMenu, runItemMenu,
264 runTechMenu, runSwitchMenu), 3 the confused menu (runConfusedMenu) and 4
265 the switch menu after a knockout (runKnockOutSwitchMenu); each sets action
266 and goes back to substate 0, which closes the children. The match depends on the menus'
267 results being switches with case -1 first and on each of the two endings
268 of the command menu's last step being written out. */
270 s32 i;
271
272 switch (task->state) {
273 case TASK_INIT:
274 default:
275 task->nextState(task);
276 break;
277 case TASK_RUN:
278 switch (task->substate) {
279 case 0:
280 default:
281 switch (task->step) {
282 case 0:
283 default:
285 for (i = 1; i < 7; i++) {
286 if (children[i].task != NULL) {
287 children[i].task->setState(children[i].task, 3);
288 }
289 }
290 task->nextStep(task);
291 break;
292 case 1:
293 break;
294 }
295 break;
296 case 1:
297 if (children[0].task == NULL) {
298 children[0].hud = FIGHTSTG_createHud();
299 }
300 task->setSubstate(task, 0);
301 break;
302 case 2:
303 switch (task->step) {
304 case 0:
305 default:
306 runCommandMenu(task, children);
307 break;
308 case 1:
309 runDigivolveMenu(task, children);
310 break;
311 case 2:
312 runItemMenu(task, children);
313 break;
314 case 3:
315 runTechMenu(task, children);
316 break;
317 case 4:
318 runSwitchMenu(task, children);
319 break;
320 }
321 break;
322 case 3:
323 runConfusedMenu(task, children);
324 break;
325 case 4:
326 runKnockOutSwitchMenu(task, children);
327 break;
328 }
329 break;
330 case 2:
331 case 3:
332 break;
333 }
334}
335
336/* Starts the player's turn (FIGHTSTG_updatePlayerTurn, id 0xE) */
340
341/* Sets the player's turn's substate, while it runs (4 picks the next fighter) */
344
345 if (task != NULL && task->state == TASK_RUN) {
346 task->setSubstate(task, substate);
347 }
348}
349
350/* Whether the player's turn has a menu open (its substate isn't 0) */
353
354 return turn->substate != 0;
355}
Battle FIGHTSTG_battle
the battle: its fighters, speed and drawing functions
Definition battle.c:16
#define BATTLE_COMMAND_ITEM
Definition menu.h:140
#define BATTLE_COMMAND_SWITCH
Definition menu.h:139
#define BATTLE_COMMAND_DIGIVOLVE
Definition menu.h:138
#define BATTLE_COMMAND_RUN
Definition menu.h:141
#define BATTLE_COMMAND_TECH
Definition menu.h:137
#define BATTLE_COMMAND_ATTACK
The command menu's lines, PlayerTurn.command.
Definition menu.h:136
#define BATTLE_TASK_PLAYER_TURN
Definition types.h:19
FIGHTSTG.PRO: the battle.
CommandMenu * FIGHTSTG_createCommandMenu(s32 start, s32 *result)
Opens the battle's command menu with the cursor on start; *result gets the command (PlayerTurn....
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
ConfusedMenu * FIGHTSTG_createConfusedMenu(s32 *result, Task *partnerView, Task *shotCamera)
Opens a confused partner's command menu; *result gets 0 for an attack or 1 for a lost turn.
DigivolveMenu * FIGHTSTG_createDigivolveMenu(s32 *result)
Opens the menu of the Digimon the partner *result can digivolve into; result gets the one picked,...
GameState GAME
The save data, the game mode and the methods.
Definition state.c:64
#define TASK_RUN
Definition task.h:35
#define TASK_INIT
Tasks: every game object is a task, a heap block that starts with this header and is updated once per...
Definition task.h:34
HpDisplay * FIGHTSTG_createHud(void)
Creates the battle HUD (FIGHTSTG_updateHud)
Definition hud.c:273
ItemMenu * FIGHTSTG_createItemMenu(s32 *result)
Opens the battle's item menu; *result gets the item picked, or -2 to go back.
Definition item_menu.c:213
PartnerView * FIGHTSTG_createPartnerView(void)
Creates the partner view (FIGHTSTG_updatePartnerView), whose children are its two cameras.
void FIGHTSTG_updatePlayerTurn(PlayerTurn *task, PlayerTurnChild *children)
The player's turn: substate 2 opens the command menu (runCommandMenu) and then the menu of its comman...
static void runTechMenu(PlayerTurn *task, PlayerTurnChild *children)
Opens the technique menu and, once a technique is picked, makes using it the action.
static void runConfusedMenu(PlayerTurn *task, PlayerTurnChild *children)
Opens the confused menu with the partner view and the shot camera, and makes its pick the action.
static void runDigivolveMenu(PlayerTurn *task, PlayerTurnChild *children)
Opens the digivolve menu for the active partner and, once a Digimon is picked, makes digivolving the ...
Definition player_turn.c:60
static void runCommandMenu(PlayerTurn *task, PlayerTurnChild *children)
Opens the command menu with the HUD, the partner view and the shot camera, then goes to the menu of t...
Definition player_turn.c:8
static void runItemMenu(PlayerTurn *task, PlayerTurnChild *children)
Opens the item menu and, once an item is picked, makes using it the action.
Definition player_turn.c:88
static void runKnockOutSwitchMenu(PlayerTurn *task, PlayerTurnChild *children)
Opens the switch menu after a knockout and then the switch-in menu, and makes the switch the action.
void FIGHTSTG_setPlayerTurnStep(s32 substate)
Sets the player's turn's substate, while it runs (4 picks the next fighter)
s32 FIGHTSTG_isPlayerChoosing(void)
Whether the player's turn has a menu open (its substate isn't 0)
PlayerTurn * FIGHTSTG_startPlayerTurn(void)
Starts the player's turn (FIGHTSTG_updatePlayerTurn, id 0xE)
static void runSwitchMenu(PlayerTurn *task, PlayerTurnChild *children)
Opens the switch menu and then the switch-in menu with the pair technique for the Digimon picked,...
TaskRegistry TASK_REGISTRY
Definition registry.c:122
ShotCamera * FIGHTSTG_createShotCamera(void)
Starts the camera that plays lists of shots (FIGHTSTG_updateShotCamera)
s32 active[2]
each side's fighter
Definition battle.h:226
BattleState state
Definition battle.h:240
s32(* getPartyMember)(u32 index)
Definition game_state.h:24
GameFuncs funcs
Definition game_state.h:582
The player's turn (FIGHTSTG_updatePlayerTurn, BATTLE_TASK_PLAYER_TURN): the battle menu,...
Definition menu.h:32
s32 arg
the action's: the item, the technique, or the party slot of the partner that digivolves or switches o...
Definition menu.h:38
s32 action
what the turn does
Definition menu.h:37
void(* setStep)(struct PlayerTurn *task, s32 step)
Definition menu.h:33
s32 pairTech
FIGHTSTG_createPairSwitchMenu's technique, which the outgoing and incoming partners do together (acti...
Definition menu.h:40
s32 digimon
the Digimon a partner changes into, or the one it switches to
Definition menu.h:39
s32 state
Definition menu.h:33
void(* nextStep)(struct PlayerTurn *task)
Definition menu.h:33
s32 result
the open menu's, -1 until it is done and -2 to go back
Definition menu.h:36
s32 counter
Definition menu.h:33
s32 switchLine
FIGHTSTG_createSwitchMenu's line, kept while the turn goes back to it.
Definition menu.h:35
void(* setCounter)(struct PlayerTurn *task, s32 counter)
Definition menu.h:33
void(* setSubstate)(struct PlayerTurn *task, s32 substate)
Definition menu.h:33
void(* nextState)(struct PlayerTurn *task)
Definition menu.h:33
void(* tickCounter)(struct PlayerTurn *task)
Definition menu.h:33
s32 substate
Definition menu.h:33
s32 command
the command menu's choice, a BATTLE_COMMAND_*
Definition menu.h:34
s32 step
Definition menu.h:33
void *(* find)(s32 id, s32 key1, s32 key2)
Definition task.h:18
TaskFuncs funcs
Definition task.h:76
Any task, seen through its header.
Definition task.h:62
void(* setSubstate)(struct Task *task, s32 substate)
Definition task.h:63
void(* setState)(struct Task *task, s32 state)
Definition task.h:63
s32 state
Definition task.h:63
SwitchInMenu * FIGHTSTG_createSwitchInMenu(s32 *result)
Opens the switch-in menu for fighter *result, without the pair technique.
SwitchInMenu * FIGHTSTG_createPairSwitchMenu(s32 *result, s32 *techResult)
Opens the switch-in menu for fighter *result, with the pair technique, which goes into *techResult.
SwitchMenu * FIGHTSTG_createSwitchMenu(s32 *result, s32 *line, s32 canCancel)
Opens the switch menu; *result gets the fighter to bring in, or -2.
void * createTaskWithId(void(*update)(), s32 size, s32 childrenSize, s32 id)
Allocates a zeroed task of size bytes (header included) with room for childrenSize / 4 child tasks.
Definition task.c:80
TechMenu * FIGHTSTG_createTechMenu(s32 *result)
Opens the battle's technique menu; *result gets the technique picked, or -2 to go back.
Definition tech_menu.c:344
One of FIGHTSTG_updatePlayerTurn's seven children: 0 the HUD, 1 the command or the confused menu,...
Definition menu.h:323
PartnerView * partnerView
Definition menu.h:328
SwitchMenu * switchMenu
Definition menu.h:332
HpDisplay * hud
Definition menu.h:325
Task * task
Definition menu.h:324
ShotCamera * shotCamera
Definition menu.h:334
TechMenu * techMenu
Definition menu.h:331
ConfusedMenu * confusedMenu
Definition menu.h:327
CommandMenu * commandMenu
Definition menu.h:326
DigivolveMenu * digivolveMenu
Definition menu.h:329
SwitchInMenu * switchInMenu
Definition menu.h:333
ItemMenu * itemMenu
Definition menu.h:330