Skip to content
🌋️
Alchemy
Theme: Weyard
Theme: Modern
Mode: Auto
Mode: Light
Mode: Dark
Alchemy
Source
Reference
Loading...
Searching...
No Matches
menu_list.h
Go to the documentation of this file.
1
#ifndef ALCHEMY_MENU_LIST_H
2
#define ALCHEMY_MENU_LIST_H
3
4
/// @file
5
/// Menu lists: sprites, cursors, the party status window and paged selections.
6
7
#include "
unit/window/window.h
"
8
#include "
unit/window/battle_command.h
"
9
#include "
types.h
"
10
#include "resource.h"
11
#include "
callback_scheduler.h
"
12
#include "
tbs_edition.h
"
13
#include "
text_render_runtime.h
"
14
#include "
window.h
"
15
#include "
static_assert.h
"
16
#include "
keystate.h
"
17
#include "
farcall.h
"
18
#include "
frame.h
"
19
20
enum
{
BATTLE_LIST_ROWS
= 5 };
21
22
/// A menu sprite: a list link and its OAM attributes, as two words or as
23
/// fields.
24
struct
MenuSprite
{
25
struct
MenuSprite
*
next
;
26
union
{
27
struct
{
28
unsigned
long
attr01
;
29
unsigned
long
attr23
;
30
}
word
;
31
struct
{
32
u16
y
: 8;
33
u16
affine
: 2;
34
u16
mode
: 2;
35
u16
mosaic
: 1;
36
u16
colors
: 1;
37
u16
shape
: 2;
38
u16
x
: 9;
39
u16
affineIndex
: 5;
40
u16
size
: 2;
41
u16
tile
: 10;
42
u16
priority
: 2;
43
u16
palette
: 4;
44
u16
unused
;
45
}
f
;
46
}
oam
;
47
};
48
49
/// A cursor or prompt sprite: a list link and its OAM attributes as fields.
50
struct
CursorSprite
{
51
struct
CursorSprite
*
next
;
52
u16
y
: 8;
53
u16
affine
: 2;
54
u16
mode
: 2;
55
u16
mosaic
: 1;
56
u16
colors
: 1;
57
u16
shape
: 2;
58
u16
x
: 9;
59
u16
affineIndex
: 5;
60
u16
size
: 2;
61
u16
tile
: 10;
62
u16
priority
: 2;
63
u16
palette
: 4;
64
u16
unused
;
65
};
66
67
#define MENU_SPRITE_SIZE_16 0x40000000
68
69
/// Sets sprite shape (attr0/attr1) and clears the remaining fields.
70
/* FAKEMATCH: the one-pass block keeps both attribute words ahead of the stores
71
* that follow (the x/y fields in the list setup loops of ItemList_SelectEntry,
72
* BattleMenu_RunActionSelection and SummonMenu_SelectSummon; the tile in
73
* UiText_DrawCharacter). Not source: the same two stores match only as plain
74
* statements in Battle_CollectPartyCommands (resource_menu.c, five times) and
75
* Ui_RunOwnerStatusScreen (preview.c, three times). */
76
#define MenuSprite_Init(sprite, shape) \
77
do { \
78
(sprite).oam.word.attr01 = (shape); \
79
(sprite).oam.word.attr23 = 0; \
80
} while (0)
81
82
/// The party status window's layout: its window, its place and size, and what
83
/// it shows (PARTY_STATUS_ flags).
84
struct
PartyStatusWindow
{
85
struct
UiWindow
*
window
;
86
u16
x
;
///< tiles
87
u16
y
;
///< tiles
88
u16
width
;
///< tiles
89
u16
height
;
///< tiles
90
u16
flags
;
///< PARTY_STATUS_ flags
91
};
92
93
STATIC_ASSERT
(
sizeof
(
struct
PartyStatusWindow
) == 16);
94
STATIC_ASSERT
(
offsetof
(
struct
PartyStatusWindow
,
flags
) == 12);
95
96
/// A point on the screen where a menu shows its cursor.
97
struct
MenuPoint
{
98
s32
x
;
///< screen pixels
99
s32
y
;
///< screen pixels
100
};
101
102
/// The battle command menus' work, heap slot 57 (0x104 bytes), reached as
103
/// gLinkCountdownWork. Battle_CollectPartyCommands allocates it each round; it
104
/// holds the icons beside the command window, the camera slide, the cursor
105
/// each list remembers, the link battle's timer, the Djinn tutorial's
106
/// key presses and what each command has spent.
107
struct
BattleMenuWork
{
108
/// The sprites UpdateLinkSessionCountdown draws each frame: the chosen
109
/// command's icon, the chosen ability's icon and the member's portrait.
110
struct
MenuSprite
icons
[3];
111
u8
iconShown
[3];
///< whether each of icons is drawn
112
u8
unk27
;
113
/// Where the battle scene slides to (Camera_ConfigureScene's vertical
114
/// offset): -2 or 16 by the target menu's mode, 0 otherwise.
115
s32
targetSceneOffset
;
116
s32
sceneOffset
;
///< where the slide has reached; a third of the way a frame
117
s32
row
;
///< the list row chosen last
118
s32
page
;
///< the list page chosen last
119
s32
preferredRow
;
///< the row to return to
120
/// The command row's choice: [0] for the party's row (fight, flee,
121
/// status), [1] for a member's commands.
122
s32
commandSelection
[2];
123
/// The window that shows the link battle's seconds left, a struct UiWindow
124
/// pointer kept as a word (as a pointer, two of the round's first stores
125
/// swap), or 0.
126
s32
timerWindow
;
127
/// Set while the status screen is open, so the timer opens no window.
128
s32
timerHidden
;
129
/// Frames left to choose commands in a link battle; -1 outside link battles.
130
/// At 0 a menu ends as if cancelled, or takes the first command.
131
s32
timer
;
132
s32
linkTimer
;
///< 1 while the link battle's timer runs
133
/// The party's standby Djinn by element before each command: what the
134
/// summons chosen by the earlier commands leave.
135
u8
standbyDjinn
[8][4];
136
u8
listSlots
[34];
///< the Psynergy list's action slots, ended by 0
137
u16
listAbilities
[33];
///< the Psynergy list's ability ids, ended by 0
138
/// The Djinn tutorial's step: 0 off, 1 from the start of each round while
139
/// FLAG_DJINN_TUTORIAL is set, then one more for each hint shown. While it
140
/// is not 0 the menus press keys for the player.
141
s32
tutorialStep
;
142
s32
tutorialDelay
;
///< frames until the tutorial's next key press
143
/// The member whose commands are being chosen; -1 between members.
144
s32
commandActor
;
145
/// The Djinni each command has chosen, element << 8 | index, or 0x80000000.
146
u32
chosenDjinn
[8];
147
};
148
149
STATIC_ASSERT
(
sizeof
(
struct
BattleMenuWork
) == 0x104);
150
STATIC_ASSERT
(
offsetof
(
struct
BattleMenuWork
, targetSceneOffset) == 0x28);
151
STATIC_ASSERT
(
offsetof
(
struct
BattleMenuWork
, row) == 0x30);
152
STATIC_ASSERT
(
offsetof
(
struct
BattleMenuWork
, commandSelection) == 0x3c);
153
STATIC_ASSERT
(
offsetof
(
struct
BattleMenuWork
, timerWindow) == 0x44);
154
STATIC_ASSERT
(
offsetof
(
struct
BattleMenuWork
, timer) == 0x4c);
155
STATIC_ASSERT
(
offsetof
(
struct
BattleMenuWork
, standbyDjinn) == 0x54);
156
STATIC_ASSERT
(
offsetof
(
struct
BattleMenuWork
, tutorialStep) == 0xd8);
157
STATIC_ASSERT
(
offsetof
(
struct
BattleMenuWork
, commandActor) == 0xe0);
158
STATIC_ASSERT
(
offsetof
(
struct
BattleMenuWork
, chosenDjinn) == 0xe4);
159
160
/// Restores the previous selection: page, row and return row.
161
// A statement macro (S2: a layer, 4 sites): the three cursor reads stay
162
// together at every use; as a plain block, tbs-en differs.
163
#define BATTLE_MENU_GET_CURSOR(page_, row_, preferred_) \
164
do { \
165
(page_) = ((struct BattleMenuWork *)gWindowWork[42])->page; \
166
(row_) = ((struct BattleMenuWork *)gWindowWork[42])->row; \
167
(preferred_) = ((struct BattleMenuWork *)gWindowWork[42])->preferredRow; \
168
} while (0)
169
170
/// Saves the selection: page, row and return row.
171
/* FAKEMATCH(one-pass): the do { } while (0) wrapper steers, so this is a device
172
* at each of its 7 sites, not a layer (S2: not every use matches through it).
173
* Battle_SelectAbility writes the same three stores plainly through its already
174
* loaded menu pointer, and through this macro it differs 2 in all six editions.
175
* At the 7 sites the work-cell pointer it loads stays
176
* apart from the reload after it, and the three stores finish before the keys
177
* are read; written as three plain stores, with the dead-store pads gone,
178
* SummonMenu_SelectSummon differs 84 (stores through its nav pointer; through
179
* gLinkCountdownWork, the macro's own stores unwrapped, it differs 4),
180
* ItemList_SelectEntry 46 and BattleMenu_RunActionSelection 42 in tbs-en, and
181
* elsewhere the row store goes first (differ 4) or the base is loaded before
182
* mode = 0 (differ 2 to 4). */
183
#define BATTLE_MENU_SET_CURSOR(page_, row_, preferred_) \
184
do { \
185
gLinkCountdownWork->page = (page_); \
186
gLinkCountdownWork->row = (row_); \
187
gLinkCountdownWork->preferredRow = (preferred_); \
188
} while (0)
189
190
extern
struct
BattleMenuWork
*
gLinkCountdownWork
;
191
extern
u8
gResource_FixedBlockBTiles
[];
192
extern
const
u8
gMenu_AnimatedCursorTiles
[];
193
194
#endif
callback_scheduler.h
The task scheduler: tasks, their order and the scheduler's state.
farcall.h
Public interfaces to the engine's code banks.
frame.h
The frame loop's globals: lag counts, the CPU load display and the VBlank flags.
gResource_FixedBlockBTiles
u8 gResource_FixedBlockBTiles[]
keystate.h
The keypad state the VBlank interrupt keeps.
gLinkCountdownWork
struct BattleMenuWork * gLinkCountdownWork
gMenu_AnimatedCursorTiles
const u8 gMenu_AnimatedCursorTiles[]
BATTLE_LIST_ROWS
@ BATTLE_LIST_ROWS
Definition
menu_list.h:20
static_assert.h
STATIC_ASSERT, a compile-time check that emits nothing.
STATIC_ASSERT
#define STATIC_ASSERT(condition)
C89 permits repeated extern declarations of the same array.
Definition
static_assert.h:15
offsetof
#define offsetof(type, member)
Definition
stddef.h:19
BattleMenuWork
The battle command menus' work, heap slot 57 (0x104 bytes), reached as gLinkCountdownWork.
Definition
menu_list.h:107
BattleMenuWork::page
s32 page
the list page chosen last
Definition
menu_list.h:118
BattleMenuWork::tutorialDelay
s32 tutorialDelay
frames until the tutorial's next key press
Definition
menu_list.h:142
BattleMenuWork::unk27
u8 unk27
Definition
menu_list.h:112
BattleMenuWork::commandActor
s32 commandActor
The member whose commands are being chosen; -1 between members.
Definition
menu_list.h:144
BattleMenuWork::listSlots
u8 listSlots[34]
the Psynergy list's action slots, ended by 0
Definition
menu_list.h:136
BattleMenuWork::linkTimer
s32 linkTimer
1 while the link battle's timer runs
Definition
menu_list.h:132
BattleMenuWork::timerWindow
s32 timerWindow
The window that shows the link battle's seconds left, a struct UiWindow pointer kept as a word (as a ...
Definition
menu_list.h:126
BattleMenuWork::preferredRow
s32 preferredRow
the row to return to
Definition
menu_list.h:119
BattleMenuWork::timerHidden
s32 timerHidden
Set while the status screen is open, so the timer opens no window.
Definition
menu_list.h:128
BattleMenuWork::listAbilities
u16 listAbilities[33]
the Psynergy list's ability ids, ended by 0
Definition
menu_list.h:137
BattleMenuWork::sceneOffset
s32 sceneOffset
where the slide has reached; a third of the way a frame
Definition
menu_list.h:116
BattleMenuWork::timer
s32 timer
Frames left to choose commands in a link battle; -1 outside link battles.
Definition
menu_list.h:131
BattleMenuWork::iconShown
u8 iconShown[3]
whether each of icons is drawn
Definition
menu_list.h:111
BattleMenuWork::standbyDjinn
u8 standbyDjinn[8][4]
The party's standby Djinn by element before each command: what the summons chosen by the earlier comm...
Definition
menu_list.h:135
BattleMenuWork::targetSceneOffset
s32 targetSceneOffset
Where the battle scene slides to (Camera_ConfigureScene's vertical offset): -2 or 16 by the target me...
Definition
menu_list.h:115
BattleMenuWork::row
s32 row
the list row chosen last
Definition
menu_list.h:117
BattleMenuWork::commandSelection
s32 commandSelection[2]
The command row's choice: [0] for the party's row (fight, flee, status), [1] for a member's commands.
Definition
menu_list.h:122
BattleMenuWork::tutorialStep
s32 tutorialStep
The Djinn tutorial's step: 0 off, 1 from the start of each round while FLAG_DJINN_TUTORIAL is set,...
Definition
menu_list.h:141
BattleMenuWork::chosenDjinn
u32 chosenDjinn[8]
The Djinni each command has chosen, element << 8 | index, or 0x80000000.
Definition
menu_list.h:146
BattleMenuWork::icons
struct MenuSprite icons[3]
The sprites UpdateLinkSessionCountdown draws each frame: the chosen command's icon,...
Definition
menu_list.h:110
CursorSprite
A cursor or prompt sprite: a list link and its OAM attributes as fields.
Definition
menu_list.h:50
CursorSprite::shape
u16 shape
Definition
menu_list.h:57
CursorSprite::tile
u16 tile
Definition
menu_list.h:61
CursorSprite::size
u16 size
Definition
menu_list.h:60
CursorSprite::priority
u16 priority
Definition
menu_list.h:62
CursorSprite::y
u16 y
Definition
menu_list.h:52
CursorSprite::palette
u16 palette
Definition
menu_list.h:63
CursorSprite::affineIndex
u16 affineIndex
Definition
menu_list.h:59
CursorSprite::x
u16 x
Definition
menu_list.h:58
CursorSprite::affine
u16 affine
Definition
menu_list.h:53
CursorSprite::colors
u16 colors
Definition
menu_list.h:56
CursorSprite::mosaic
u16 mosaic
Definition
menu_list.h:55
CursorSprite::mode
u16 mode
Definition
menu_list.h:54
CursorSprite::next
struct CursorSprite * next
Definition
menu_list.h:51
CursorSprite::unused
u16 unused
Definition
menu_list.h:64
MenuPoint
A point on the screen where a menu shows its cursor.
Definition
menu_list.h:97
MenuPoint::y
s32 y
screen pixels
Definition
menu_list.h:99
MenuPoint::x
s32 x
screen pixels
Definition
menu_list.h:98
MenuSprite::[union].oam::[struct].oam.f::tile
u16 tile
MenuSprite::[union].oam::[struct].oam.f::palette
u16 palette
MenuSprite::[union].oam::[struct].oam.f::mosaic
u16 mosaic
MenuSprite::[union].oam::[struct].oam.f::mode
u16 mode
MenuSprite::[union].oam::[struct].oam.f::size
u16 size
MenuSprite::[union].oam::[struct].oam.f::affineIndex
u16 affineIndex
MenuSprite::[union].oam::[struct].oam.f::y
u16 y
MenuSprite::[union].oam::[struct].oam.f::affine
u16 affine
MenuSprite::[union].oam::[struct].oam.f::unused
u16 unused
MenuSprite::[union].oam::[struct].oam.f::colors
u16 colors
MenuSprite::[union].oam::[struct].oam.f::x
u16 x
MenuSprite::[union].oam::[struct].oam.f::priority
u16 priority
MenuSprite::[union].oam::[struct].oam.f::shape
u16 shape
MenuSprite::[union].oam::[struct].oam.word::attr23
unsigned long attr23
MenuSprite::[union].oam::[struct].oam.word::attr01
unsigned long attr01
MenuSprite
A menu sprite: a list link and its OAM attributes, as two words or as fields.
Definition
menu_list.h:24
MenuSprite::next
struct MenuSprite * next
Definition
menu_list.h:25
MenuSprite::oam
union MenuSprite::@002225022013150231017316170057321303227123371224 oam
PartyStatusWindow
The party status window's layout: its window, its place and size, and what it shows (PARTY_STATUS_ fl...
Definition
menu_list.h:84
PartyStatusWindow::height
u16 height
tiles
Definition
menu_list.h:89
PartyStatusWindow::y
u16 y
tiles
Definition
menu_list.h:87
PartyStatusWindow::width
u16 width
tiles
Definition
menu_list.h:88
PartyStatusWindow::x
u16 x
tiles
Definition
menu_list.h:86
PartyStatusWindow::flags
u16 flags
PARTY_STATUS_ flags.
Definition
menu_list.h:90
PartyStatusWindow::window
struct UiWindow * window
Definition
menu_list.h:85
UiWindow
A window: a framed rectangle of the tilemap with its sprite outputs, its opening or closing animation...
Definition
uiwindow.h:11
UiWindow::flags
u16 flags
UI_WINDOW_ flags; 0 once closing or free.
Definition
uiwindow.h:25
tbs_edition.h
Values that differ by patch level or language, chosen once for their code.
text_render_runtime.h
Declares nothing of its own: it only includes edition.h and render_input.h.
types.h
The integer types, TRUE, UNUSED and the fixed-address macros.
s32
signed int s32
Definition
types.h:14
u32
unsigned int u32
Definition
types.h:15
u16
unsigned short u16
Definition
types.h:13
u8
unsigned char u8
Definition
types.h:11
MenuSprite::[union].oam::word
struct MenuSprite::@002225022013150231017316170057321303227123371224::@325330370321370255050363352365103065001073105301 word
MenuSprite::[union].oam::f
struct MenuSprite::@002225022013150231017316170057321303227123371224::@041012054333166274217104264025345003373326225271 f
battle_command.h
window.h
window.h
The window renderer's work.
include
menu_list.h