Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
command_menu.c
Go to the documentation of this file.
1/* FIGHTSTG's command menu, the six commands of the player's turn. */
2
4
5/* Shows the six commands once, greying out attack, techniques and digivolve
6 when the active fighter is asleep and digivolve when it has flag 0x20 (the
7 first window's setPalette is called for each) */
10 BattleFighter *fighter;
11 char *text;
12 s32 i;
13
14 if (w->lines[0] == NULL) {
16 for (i = 0; i < BATTLE_COMMAND_COUNT; i++) {
17 w->lines[i] = createTextWindow(BATTLE_LAYER_MENUS, 1, 0x24, 0x6D + i * 0x13);
18 w->lines[i]->setString(w->lines[i], text, i + 1);
19 }
21 if (fighter->flags & FIGHTER_ASLEEP) {
22 for (i = 0; i < BATTLE_COMMAND_SWITCH; i++) {
23 w->lines[0]->setPalette(w->lines[i], PALETTE_GREY);
24 }
25 }
26 if (fighter->flags & FIGHTER_NO_DIGIVOLVE) {
28 }
29 }
30}
31
32/* the battle commands' cursor (FIGHTSTG_createCursor makes the menus' cursors from
33 these layouts) */
35 6, 17, 110, 19, 34, 16, 109, 19,
36};
37
38/* The command menu's task: puts a cursor (FIGHTSTG_commandCursor) on the
39 * lines, starting on start; cross picks the line into *result and locks the
40 * cursor, but not the greyed-out ones (FIGHTSTG_showCommands).
41 * The match depends on the early exits being breaks out of a do/while. */
43 BattleFighter *fighter;
44
45 switch (task->state) {
46 case TASK_INIT:
47 default:
49 w->cursor->sel = task->start;
51 task->nextState(task);
52 break;
53 case TASK_RUN:
54 do {
55 if (!(PAD.getPressed(0) & (1 << PAD_CROSS))) {
56 break;
57 }
60 if ((fighter->flags & FIGHTER_ASLEEP) && w->cursor->sel < BATTLE_COMMAND_SWITCH) {
61 break;
62 }
64 break;
65 }
66 *task->result = w->cursor->sel;
67 task->setState(task, 3);
68 w->cursor->locked = 1;
69 } while (0);
70 break;
71 case TASK_DONE:
72 case TASK_KILL:
73 break;
74 }
75}
76
77/* Opens the battle's command menu with the cursor on start; *result gets
78 the command (PlayerTurn.command) */
81
82 task->result = result;
83 *result = -1;
84 task->start = start;
85 return task;
86}
Battle FIGHTSTG_battle
the battle: its fighters, speed and drawing functions
Definition battle.c:16
#define FIGHTER_NO_DIGIVOLVE
can't digivolve or use a switch-in technique (TECH_EFFECT_NO_DIGIVOLVE)
Definition battle.h:187
#define FIGHTER_ASLEEP
can't act or run away; a hit may wake it up
Definition battle.h:185
MenuCursor * FIGHTSTG_createCursor(CursorLayout *layout)
Creates a menu cursor laid out by layout.
Definition cursor.c:136
#define BATTLE_COMMAND_SWITCH
Definition menu.h:139
#define BATTLE_COMMAND_DIGIVOLVE
Definition menu.h:138
#define BATTLE_COMMAND_COUNT
Definition menu.h:142
#define BATTLE_LAYER_MENUS
the HUD, the menus and the messages
Definition types.h:31
FIGHTSTG.PRO: the battle.
CursorLayout FIGHTSTG_commandCursor
the battle commands' cursor (FIGHTSTG_createCursor makes the menus' cursors from these layouts)
CommandMenu * FIGHTSTG_createCommandMenu(s32 start, s32 *result)
Opens the battle's command menu with the cursor on start; *result gets the command (PlayerTurn....
void FIGHTSTG_updateCommandMenu(CommandMenu *task, CommandMenuWindows *w)
The command menu's task: puts a cursor (FIGHTSTG_commandCursor) on the lines, starting on start; cros...
void FIGHTSTG_showCommands(CommandMenu *task)
Shows the six commands once, greying out attack, techniques and digivolve when the active fighter is ...
Definition command_menu.c:8
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
#define TASK_RUN
Definition task.h:35
#define TASK_KILL
Definition task.h:37
#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
#define TASK_DONE
Definition task.h:36
#define TEXT_BATTLE_MENU
MFIGHT: WFIGHTMN's.
Definition file.h:218
#define TEXT_FILE(file)
Definition file.h:190
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
PadState PAD
Controller input: cleared by initPad, then the methods.
Definition pad.c:168
#define PAD_CROSS
Definition pad.h:31
SoundState SOUND
rsin and rcos (libgte) read rsin_tbl[a - 0x800] and the like: their addresses before the table fall i...
Definition sound.c:180
#define SOUND_MENU_CONFIRM
SYSTEM07.
Definition sound.h:44
Task * start(void)
The mode's entry point (MODE_ENTRY_POINTS): starts its root task (update_scene.inc....
Definition start.inc.c:3
One of the battle's fighters, three on each side (WFIGHTMN's BattleUnit): a partner's HP and MP go ba...
Definition battle.h:191
u8 flags
FIGHTER_*.
Definition battle.h:204
s32 active[2]
each side's fighter
Definition battle.h:226
BattleFighter fighters[2][3]
Definition battle.h:227
BattleState state
Definition battle.h:240
FIGHTSTG_updateCommandMenu's children: a cursor over six lines.
Definition menu.h:152
struct MenuCursor * cursor
Definition menu.h:153
TextWindow * lines[6]
Definition menu.h:154
The battle's command menu (FIGHTSTG_createCommandMenu)
Definition menu.h:145
s32 state
Definition menu.h:146
void * children
Definition menu.h:146
void(* nextState)(struct CommandMenu *task)
Definition menu.h:146
s32 start
the line the cursor starts on
Definition menu.h:147
void(* setState)(struct CommandMenu *task, s32 state)
Definition menu.h:146
s32 * result
-1 until it is done
Definition menu.h:148
A menu cursor's layout, which FIGHTSTG_createCursor copies into its task: a highlight bar over count ...
Definition menu.h:288
void *(* load)(u32 file)
Definition file.h:92
s32 sel
Definition menu.h:304
s32 locked
Definition menu.h:305
s32(* getPressed)(s32 pad)
Definition pad.h:125
short(* playSound)(s32 id)
returns the voice of a key-on
Definition sound.h:187
void(* setPalette)(struct TextWindow *obj, u8 arg)
Definition text.h:174
void(* setString)()
Definition text.h:165
void * createTask(void(*update)(), s32 size, s32 childrenSize)
createTaskWithId for a task nothing needs to find
Definition task.c:105
#define PALETTE_GREY
what is unavailable
Definition text.h:119
TextWindow * createTextWindow(s16 layerId, s16 style, s16 x, s16 y)
A text window on a layer, in a font style, at (x, y)