Alchemy
Loading...
Searching...
No Matches

battle_command_internal.h

Go to the documentation of this file.
1#ifndef ALCHEMY_BATTLE_COMMAND_INTERNAL_H
2#define ALCHEMY_BATTLE_COMMAND_INTERNAL_H
3
4/// @file
5/// What every part of the menu object shares: its includes, edition values,
6/// macros and the link round state. battle_command.c includes it before the
7/// parts, and each part includes it too, so that a part read on its own still
8/// resolves.
9
10#include "render_placement.h"
11#include "unit/window/window.h"
13#include "unit/object/object.h"
16#include "types.h"
17#include "edition.h"
18#include "window.h"
19#include "battle.h"
20#include "keystate.h"
21#include "debug.h"
22#include "field.h"
23#include "game.h"
24#include "graphics.h"
25#include "menu.h"
26#include "minigame.h"
27#include "sound.h"
28#include "system.h"
29#include "mem.h"
30#include "callback_scheduler.h"
31#include "dma.h"
32#include "tbs_edition.h"
33#include "iwram_call.h"
34#include "io_reg.h"
35#include "global_cells.h"
36#include "menu_list.h"
37#include "render_input.h"
38#include "resource.h"
39#include "output.h"
40#include "glyph.h"
41#include "game_state.h"
42#include "battle_work.h"
43#include "heap_state.h"
44#include "text_font.h"
45#include "text_render_runtime.h"
46#include "fixed_math.h"
47#include "runtime_interfaces.h"
48#include "resource_ids.h"
49#include "ramcode.h"
50#include "affine.h"
51#include "battle_party.h"
52#include "scene.h"
53#include "text_reader.h"
54#include "lib.h"
55#include "battle_unit.h"
56#include "battle_system.h"
57#include "item.h"
58#include "vram_block.h"
59#include "select.h"
60#include "node_chain.h"
61#include "text/msg_ids.h"
62#include "songs.h"
63#include "flags.h"
64#include "static_assert.h"
65#include "field_event.h"
66#include "b5_context.h"
67#include "battle_type.h"
68#include "uiflow.h"
69#include "owner_state.h"
70#include "workspace_options.h"
71#include "ram_buffer.h"
72#include "party_state.h"
73#include "save_state.h"
74#include "irq.h"
75#include "character_menu.h"
76#include "animspr.h"
77#include "four_object_motion.h"
78#include "uiwindow.h"
79#include "io_write_queue.h"
80#include "map_scroll.h"
81#include "vram_tab.h"
82#include "djinn_preview.h"
83#include "ui.h"
84#include "motobj.h"
85#include "effect_step.h"
86#include "resource_menu.h"
87#include "battle_summon.h"
88#include "serial_runtime.h"
89#include "battle_effect_work.h"
90#include "shop.h"
91#include "display_transition.h"
92#include "frame.h"
94#include "unit/window/scales.h"
95
96#ifdef MODERN
97// The menu object calls these window functions with no prototype in scope, as
98// its bytes need (unit/window/window.h says why for each); a current GCC gets
99// them here.
101 struct RenderOutput *node);
103 s32 entry, s32 x, s32 y,
104 u16 *spacing, s32 flags);
105void UiText_RenderWideStringInWindow(s16 *text, struct UiWindow *window, s32 x,
106 s32 y);
107void UiWindow_PutGlyph(struct UiWindow *win, u32 tile, u32 x, u32 y, s32 mode);
108void UiText_DrawPrefixedNumberAtOffset(s32 value, const struct UiWindow *work,
109 s32 offsetX, s32 offsetY, s32 variant);
110#endif
111
112// Edition-specific text and window layout values.
113#if !TBS_PATCH_1
114#define DJINN_PREVIEW_VITALS_X 4
115#else
116#define DJINN_PREVIEW_VITALS_X 5
117#endif
118
119#if !TBS_PATCH_1
120#define DJINN_PREVIEW_STAT_DIGIT_OFFSET 7
121#define DJINN_PREVIEW_STAT_X 4
122#else
123#define DJINN_PREVIEW_STAT_DIGIT_OFFSET 8
124#define DJINN_PREVIEW_STAT_X 6
125#endif
126
127#if !TBS_PATCH_1
128#define DJINN_PREVIEW_HELP_X 40
129#else
130#define DJINN_PREVIEW_HELP_X 24
131#endif
132
133#if (LANGUAGE == LANGUAGE_SPANISH) || (LANGUAGE == LANGUAGE_FRENCH) || \
134 (LANGUAGE == LANGUAGE_ITALIAN)
135#define PSYNERGY_COST_SECOND_TILE 0xf005
136#else
137#define PSYNERGY_COST_SECOND_TILE 0xf01e
138#endif
139
140#if (LANGUAGE == LANGUAGE_FRENCH)
141#define OWNER_STATUS_LEVEL_X 51
142#else
143#define OWNER_STATUS_LEVEL_X 56
144#endif
145
146#if TBS_PATCH_1
147#define SUMMON_MENU_WINDOW_X 13
148#define SUMMON_MENU_WINDOW_WIDTH 17
149#else
150#define SUMMON_MENU_WINDOW_X 16
151#define SUMMON_MENU_WINDOW_WIDTH 14
152#endif
153
154#if TBS_PATCH_1
155#define BATTLE_CLASS_ICON_X 0
156#else
157#define BATTLE_CLASS_ICON_X 4
158#endif
159
160#if (LANGUAGE == LANGUAGE_FRENCH)
161#define BATTLE_COMMAND_NAME_X 14
162#else
163#define BATTLE_COMMAND_NAME_X 16
164#endif
165
166#if TBS_PATCH_1
167#define BATTLE_SUMMON_ICON_X 80
168#else
169#define BATTLE_SUMMON_ICON_X 104
170#endif
171
172#if TBS_PATCH_1
173#define BATTLE_SUMMON_WINDOW_WIDTH 17
174#else
175#define BATTLE_SUMMON_WINDOW_WIDTH 14
176#endif
177
178#if TBS_PATCH_1
179#define BATTLE_SUMMON_ELEMENT_COLUMN 13
180#define BATTLE_SUMMON_COST_COLUMN 14
181#else
182#define BATTLE_SUMMON_ELEMENT_COLUMN 10
183#define BATTLE_SUMMON_COST_COLUMN 11
184#endif
185
186#if (LANGUAGE == LANGUAGE_GERMAN) || (LANGUAGE == LANGUAGE_SPANISH) || \
187 (LANGUAGE == LANGUAGE_FRENCH) || (LANGUAGE == LANGUAGE_ITALIAN)
188#define BATTLE_ITEM_WINDOW_WIDTH 16
189#else
190#define BATTLE_ITEM_WINDOW_WIDTH 15
191#endif
192
193#if (LANGUAGE == LANGUAGE_ENGLISH) || (LANGUAGE == LANGUAGE_GERMAN) || \
194 (LANGUAGE == LANGUAGE_ITALIAN)
195#define RESOURCE_MODE0_WINDOW_X 7
196#define RESOURCE_MODE0_WINDOW_WIDTH 17
197#elif (LANGUAGE == LANGUAGE_SPANISH)
198#define RESOURCE_MODE0_WINDOW_X 5
199#define RESOURCE_MODE0_WINDOW_WIDTH 21
200#elif (LANGUAGE == LANGUAGE_FRENCH)
201#define RESOURCE_MODE0_WINDOW_X 5
202#define RESOURCE_MODE0_WINDOW_WIDTH 22
203#else
204#define RESOURCE_MODE0_WINDOW_X 9
205#define RESOURCE_MODE0_WINDOW_WIDTH 13
206#endif
207
208#if (LANGUAGE == LANGUAGE_GERMAN)
209#define RESOURCE_MODE1_WINDOW_X 1
210#define RESOURCE_MODE1_WINDOW_WIDTH 28
211#else
212#define RESOURCE_MODE1_WINDOW_X 3
213#define RESOURCE_MODE1_WINDOW_WIDTH 25
214#endif
215
216#if (LANGUAGE == LANGUAGE_ENGLISH) || (LANGUAGE == LANGUAGE_GERMAN)
217#define TRANSFER_METHOD_WINDOW_X 6
218#define TRANSFER_METHOD_WINDOW_WIDTH 18
219#elif (LANGUAGE == LANGUAGE_SPANISH)
220#define TRANSFER_METHOD_WINDOW_X 4
221#define TRANSFER_METHOD_WINDOW_WIDTH 21
222#elif (LANGUAGE == LANGUAGE_FRENCH) || (LANGUAGE == LANGUAGE_ITALIAN)
223#define TRANSFER_METHOD_WINDOW_X 5
224#define TRANSFER_METHOD_WINDOW_WIDTH 20
225#else
226#define TRANSFER_METHOD_WINDOW_X 9
227#define TRANSFER_METHOD_WINDOW_WIDTH 13
228#endif
229
230#if TBS_PATCH_1
231#define TRANSFER_METHOD_LABEL_X 2
232#else
233#define TRANSFER_METHOD_LABEL_X 0
234#endif
235
236#if (LANGUAGE == LANGUAGE_ENGLISH) || (LANGUAGE == LANGUAGE_SPANISH) || \
237 (LANGUAGE == LANGUAGE_FRENCH) || (LANGUAGE == LANGUAGE_ITALIAN)
238#define TRANSFER_HELP_WINDOW_X 1
239#define TRANSFER_HELP_WINDOW_WIDTH 28
240#elif (LANGUAGE == LANGUAGE_GERMAN)
241#define TRANSFER_HELP_WINDOW_X 0
242#define TRANSFER_HELP_WINDOW_WIDTH 30
243#else
244#define TRANSFER_HELP_WINDOW_X 5
245#define TRANSFER_HELP_WINDOW_WIDTH 21
246#endif
247
248#if (LANGUAGE == LANGUAGE_GERMAN)
249#define ENTRY11_COMMAND_LABEL_WIDTH 8
250#elif TBS_PATCH_1
251#define ENTRY11_COMMAND_LABEL_WIDTH 7
252#else
253#define ENTRY11_COMMAND_LABEL_WIDTH 6
254#endif
255
256#if TBS_PATCH_1
257#define ENTRY19_COMMAND_LABEL_WIDTH 10
258#else
259#define ENTRY19_COMMAND_LABEL_WIDTH 8
260#endif
261
262/// OAM attribute bits a sprite output is created with: the size field of
263/// attribute 1 (bits 30-31 of the first word). A square sprite of size 1 is
264/// 16x16 pixels, of size 2 32x32.
265#define OUTPUT_SIZE_16X16 0x40000000
266#define OUTPUT_SIZE_32X32 0x80000000
267
268// The two portrait slots of the UI work, and the palette the first one uses
269// (the second uses the next).
270#define PORTRAIT_SLOT_COUNT 2
271#define PORTRAIT_PALETTE 14
272#define PORTRAIT_SLOT_EMPTY 999
273
274// The battle menus' message buffers, in halfwords, and the copier that fills
275// them.
276#if TBS_PATCH_1
277#define BATTLE_MENU_MESSAGE_CAPACITY 52
278#define BATTLE_MENU_MESSAGE_COPY UiText_CopyMessageString
279#else
280#define BATTLE_MENU_MESSAGE_CAPACITY 32
281#define BATTLE_MENU_MESSAGE_COPY UiText_DecodeMessage
282#endif
283
284/// Tiles the battle lists draw over their window's top edge: the page numbers
285/// and arrows, and the summon list's element icon.
286enum {
287 SUMMON_ELEMENT_TILE = 0x5001, ///< Element icon
288 LIST_TILE_PAGE_NUMBER = 0xf301, ///< Page number
289 LIST_TILE_PAGE_NUMBER_LIT = 0xf30b, ///< Current page number
290 LIST_TILE_PAGES_LEFT = 0xf334, ///< Left arrow
291 LIST_TILE_PAGES_RIGHT = 0xf335 ///< Right arrow
292};
293
294#define BATTLE_OK 0x80 ///< flags: usable in battle
295
296/// The command icon row's work block and one of its icons: pictures.c loads
297/// the icons, command_row.c runs the row.
303};
304
305/// The command icon row's work block: the icons' shared palette, up to six
306/// icons, the label window, the pulsing icon's transform and the selection.
315};
316
317// The Djinn menu's blinking tile, and where each element's Djinn count sits in
318// the party status window, in tiles, to blink while it has Djinn on standby
319// (windata.s).
320extern const u8 gDjinnMenu_BlinkTile[32];
321extern const u8 gDjinnMenu_ElementXOffsets[4];
322extern const u8 gDjinnMenu_ElementYOffsets[4];
323
324#endif
Sprite rotation and scale, and the affine matrices handed out each frame.
Animated sprites: their layers, frames and colour modes, and the resource slots they draw from.
B5Context, the object context a battle routine reads; most of its fields are still unnamed.
const u8 gDjinnMenu_BlinkTile[32]
@ LIST_TILE_PAGES_RIGHT
Right arrow.
@ SUMMON_ELEMENT_TILE
Element icon.
@ LIST_TILE_PAGE_NUMBER
Page number.
@ LIST_TILE_PAGES_LEFT
Left arrow.
@ LIST_TILE_PAGE_NUMBER_LIT
Current page number.
const u8 gDjinnMenu_ElementYOffsets[4]
const u8 gDjinnMenu_ElementXOffsets[4]
BattleEffectWork, the running battle effect's work, and its animation objects.
Which units are in a battle, and the Djinn recovery list.
Summons and the battle sprite definitions of the enemy classes.
BattleUnit_Recalculate, which recalculates a unit's stats.
BattlePlan, an action planned for its targets: the hits, criticals and multipliers rolled.
BattleUnit, a party member's or enemy's battle state, with the elements, abilities and actions it use...
BattleWork, the battle's own work, and the battle display work.
The task scheduler: tasks, their order and the scheduler's state.
The character menu's state, and the ailments it shows.
The engine calls the debug menus import, and their palette swatch tiles.
The display transition's frames, windows and state.
The Djinn preview's sprites and arrow tiles.
DMA channel registers, and the DMA and CPU fills.
The edition's language, for C to compare (LANGUAGE == LANGUAGE_GERMAN).
EffectStep and EffectPosition, the positions effects move through.
The scene script layer: the engine services a scene's events call, declared once (Engine_EventBegin,...
16.16 fixed-point constants, sine and cosine, and the library division.
Game flags, named where their meaning is shown.
FourObjectMotion, the row of four figures the Status and Djinn menus show.
The frame loop's globals: lag counts, the CPU load display and the VBlank flags.
GameState, the game's state: play time, coins, the scene and the leader's position,...
The work slots of gWorkSlot, read through their own names.
Font glyphs and their palettes.
void UiText_RenderWideStringInWindow(s16 *text, struct UiWindow *window, s32 x, s32 y)
Draws a zero-terminated string of 16-bit character codes into a window's tilemap at tile (x,...
Definition glyphs.c:409
The screen blend's globals and the graphics routines.
The heap's work slots and HeapState.
The hardware's I/O registers and their bits, as pret names them.
The register write queue that VBlank carries out after each finished frame.
The hardware's interrupt sources and the interrupt handler table.
Items: their definitions, types, flags and effects.
The IWRAM call layer: the routines the game keeps resident in IWRAM, each at its fixed address,...
The keypad state the VBlank interrupt keeps.
Declares nothing of its own: it only includes types.h and edition.h.
The map layers' scroll work and the background scroll values.
The heaps: allocating and freeing blocks.
Menu lists: sprites, cursors, the party status window and paged selections.
The reel game's title lettering.
MotionObject, an effect object that moves and draws one sprite.
NodeChain, a chain of menu nodes.
Declares nothing of its own: it only includes edition.h and render_input.h.
Declares nothing of its own: it only includes battle_system.h.
Declares nothing of its own: it only includes static_assert.h and game_state.h.
The work pointers in the gWorkSlot table, by name.
Copying ARM routines to RAM to run them there.
The sprite renderer's inputs and outputs: render inputs, OAM attributes and render output lists.
A sprite's screen position and scale.
Resource numbers, named where their contents are known.
The resource menu's entries and work.
Declares nothing of its own: it only includes edition.h and types.h.
The save workspace: slot headers and summaries.
FIELD_AT_OFFSET and the entity and camera views older scene code reads.
The selection screen's sprites and nodes.
The link cable's runtime: serial packets, registers and transfer state.
ShopRuntime, a shop's work, and the shop screen's tiles.
Song and sound effect ids, indices into gSound_SongTable.
STATIC_ASSERT, a compile-time check that emits nothing.
A sprite's rotation and scale: scales in 8.8 fixed point (0x100 is full size), the angle in 1/65536 t...
Definition affine.h:13
A compact palette shared by a selection's command icons: the slot each icon colour was given,...
Definition glyph.h:19
A menu sprite: a list link and its OAM attributes, as two words or as fields.
Definition menu_list.h:24
A list of render outputs: its first output and the link to append after.
A render output: a sprite in a window's output list (a character, an icon or a portrait),...
The command icon row's work block and one of its icons: pictures.c loads the icons,...
struct MenuSprite sprite
The command icon row's work block: the icons' shared palette, up to six icons, the label window,...
struct GlyphPalette palette
struct SelectionEntry entries[6]
struct UiWindow * window
struct AffineTransform affine
A text channel, one of three, which types decoded text into a window a few characters a frame and run...
Definition uiwindow.h:43
u16 y
pen, 8.8 fixed-point pixels
Definition uiwindow.h:46
u16 flags
nonzero keeps the window's size from page to page
Definition uiwindow.h:60
u16 x
pen, 8.8 fixed-point pixels
Definition uiwindow.h:45
u16 spacing[4]
Extra advance per line, in 1/256 pixels: after every character in Japanese, after a space in the othe...
Definition uiwindow.h:49
struct UiWindow * work
the window typed into; NULL when free
Definition uiwindow.h:44
u16 entry
next code in UiRenderWork.entries
Definition uiwindow.h:51
A window: a framed rectangle of the tilemap with its sprite outputs, its opening or closing animation...
Definition uiwindow.h:11
The system's routines and globals: interrupts, BIOS sound bias, random numbers and sleep.
Values that differ by patch level or language, chosen once for their code.
The kanji glyphs and the text marks drawn with characters.
TextReader, a cursor through message text.
Declares nothing of its own: it only includes edition.h and render_input.h.
void UiText_DrawPrefixedNumberAtOffset(s32 value, const struct UiWindow *work, s32 offsetX, s32 offsetY, s32 variant)
Draws a four-digit number after a two-glyph sign (window tiles 0x1d and 0x1e, or 0x1f and 0x1e with v...
Definition text_tiles.c:689
The integer types, TRUE, UNUSED and the fixed-address macros.
signed int s32
Definition types.h:14
unsigned int u32
Definition types.h:15
signed short s16
Definition types.h:12
unsigned short u16
Definition types.h:13
unsigned char u8
Definition types.h:11
UiWork, the window system's work, and the status screen's cursors.
Declares nothing of its own: it only includes edition.h and uiwindow.h.
UiWindow, a window's work, and marking its tilemap rows for transfer.
Declares nothing of its own: it only includes the window, battle command, resource and VRAM table hea...
The sprite VRAM block cache and its owners.
void UiWindow_PutGlyph(struct UiWindow *win, u32 tile, u32 x, u32 y, s32 mode)
Puts a character into a window's tilemap as a tile at tile (x, y) of its interior.
Definition sprites.c:187
The window renderer's work.
void RenderOutput_AppendToList(struct RenderOutputList *list, struct RenderOutput *node)
Adds a render output to the end of a list; NULL lists are ignored.
Definition windows.c:478
struct UiChannelSlot * UiText_QueueRenderEntries(struct UiWindow *window, s32 entry, s32 x, s32 y, u16 *spacing, s32 flags)
Starts a free message channel typing the decoded text that begins at entry into window,...
Definition windows.c:515
The options screen's work and the selection work.