Alchemy
Loading...
Searching...
No Matches

window_internal.h

Go to the documentation of this file.
1#ifndef ALCHEMY_WINDOW_INTERNAL_H
2#define ALCHEMY_WINDOW_INTERNAL_H
3
4/// @file
5/// What every part of the window object shares: its includes, edition values,
6/// macros and the codes of decoded text. window.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 "unit/window/scales.h"
13#include "unit/window/window.h"
15#include "unit/object/object.h"
19#include "types.h"
20#include "edition.h"
21#include "window.h"
22#include "battle.h"
23#include "keystate.h"
24#include "debug.h"
25#include "field.h"
26#include "game.h"
27#include "graphics.h"
28#include "menu.h"
29#include "minigame.h"
30#include "sound.h"
31#include "system.h"
32#include "mem.h"
33#include "callback_scheduler.h"
34#include "dma.h"
35#include "tbs_edition.h"
36#include "iwram_call.h"
37#include "io_reg.h"
38#include "global_cells.h"
39#include "menu_list.h"
40#include "render_input.h"
41#include "resource.h"
42#include "output.h"
43#include "glyph.h"
44#include "game_state.h"
45#include "battle_work.h"
46#include "heap_state.h"
47#include "text_font.h"
48#include "text_render_runtime.h"
49#include "fixed_math.h"
50#include "runtime_interfaces.h"
51#include "resource_ids.h"
52#include "ramcode.h"
53#include "affine.h"
54#include "battle_party.h"
55#include "scene.h"
56#include "text_reader.h"
57#include "lib.h"
58#include "battle_unit.h"
59#include "battle_system.h"
60#include "item.h"
61#include "vram_block.h"
62#include "select.h"
63#include "text/msg_ids.h"
64#include "songs.h"
65#include "static_assert.h"
66#include "field_event.h"
67#include "b5_context.h"
68#include "battle_type.h"
69#include "uiflow.h"
70#include "owner_state.h"
71#include "workspace_options.h"
72#include "ram_buffer.h"
73#include "party_state.h"
74#include "save_state.h"
75#include "irq.h"
76#include "character_menu.h"
77#include "animspr.h"
78#include "four_object_motion.h"
79#include "uiwindow.h"
80#include "io_write_queue.h"
81#include "map_scroll.h"
82#include "vram_tab.h"
83#include "djinn_preview.h"
84#include "ui.h"
85#include "motobj.h"
86#include "effect_step.h"
87#include "resource_menu.h"
88#include "battle_summon.h"
89#include "serial_runtime.h"
90#include "battle_effect_work.h"
91#include "shop.h"
92#include "display_transition.h"
93#include "frame.h"
94#include "macros.h"
95#include "flags.h"
96
97// Edition-specific text and window layout values.
98#if (LANGUAGE == LANGUAGE_SPANISH)
99#define ITEM_POSSESSIVE_TEXT_COUNT 2
100#else
101#define ITEM_POSSESSIVE_TEXT_COUNT 4
102#endif
103
104#if (LANGUAGE == LANGUAGE_GERMAN) || (LANGUAGE == LANGUAGE_SPANISH) || \
105 (LANGUAGE == LANGUAGE_FRENCH) || (LANGUAGE == LANGUAGE_ITALIAN)
106#define TEXT_ARGUMENT_SPACE ' '
107#else
108#define TEXT_ARGUMENT_SPACE 143
109#endif
110
111#if (LANGUAGE == LANGUAGE_JAPANESE)
112#define UI_SPRITE_SPACE_WIDTH 7
113#else
114#define UI_SPRITE_SPACE_WIDTH 5
115#endif
116
117#ifdef MODERN
118// In the matching build these calls precede their declarations. Prototypes
119// reorder three argument moves for ClearTileAttributesInRect and two for
120// PutGlyph in the English image.
121void UiWindow_PutGlyph(struct UiWindow *win, u32 tile, u32 x, u32 y, s32 mode);
122void UiWindow_ClearTileAttributesInRect(s32 x, s32 y, u32 width, u32 height);
123#endif
124
125/// A glyph resource id meaning no glyph resource is loaded.
126#define NO_GLYPH_RESOURCE 99
127
128// UiRenderWork owns three message channels, each with four line gaps.
129#define UI_MESSAGE_CHANNEL_COUNT 3
130#define UI_MESSAGE_LINE_COUNT 4
131#define UI_TEXT_DEFAULT_COLOUR 15
132#define UI_TEXT_DEFAULT_LINE_SPACING 10
133#define UI_TILEMAP_PALETTE 15
134
135// Window animation lengths and the palette slot's unused marker.
136#define UI_WINDOW_OPEN_FRAMES 8
137#define UI_WINDOW_CLOSE_FRAMES 4
138#define UI_PALETTE_SLOT_FREE 999
139#define UI_CANVAS_BACKGROUND_WORD 0x44444444
140
141// Scratch capacities are in bytes unless the name says halfwords.
142#define UI_NUMBER_BUFFER_SIZE 16
143#define UI_BYTE_STRING_BUFFER_SIZE 0x200
144#define UI_MESSAGE_NAME_HALFWORDS 24
145#define UI_ARGUMENT_SLOT_COUNT 8
146#define UI_SELECTION_ENTRY_LIMIT 16
147#define UI_AREA_NOTICE_FRAMES 90
148
149/// The control codes of decoded message text (UiRenderWork.entries). Codes
150/// from TEXT_SPACE up are characters.
151enum {
153 TEXT_PAGE = 1, ///< wait for a button, then clear the window for a new page
154 TEXT_WAIT_KEY = 2, ///< wait for a button, then close the window
156 TEXT_PAUSE_LONG = 4, ///< a 60-frame pause
157 TEXT_PAUSE_SHORT = 5, ///< a 20-frame pause a button can cut short
158 TEXT_PAUSE_LONGEST = 6, ///< a 120-frame pause a button can cut short
160 TEXT_COLOUR = 8, ///< the next entry is the text colour
161 TEXT_OUTLINE = 9, ///< the next entry is the outline colour
162 TEXT_LINE_SPACING = 10, ///< the next entry is the line spacing
163 TEXT_WINDOW_STATE = 15, ///< the next entry is the window effect to run
167 TEXT_VOICED_MARK = 222, ///< dakuten
168 TEXT_SEMIVOICED_MARK = 223 ///< handakuten
169};
170
171// The kana mark drawn with a character, in the top two bits of its code (the
172// index into gUiText_MarkGlyphCodes).
173#define TEXT_CODE_MARK_SHIFT 14
174#define TEXT_CODE_VOICED (1 << TEXT_CODE_MARK_SHIFT)
175#define TEXT_CODE_SEMIVOICED (2 << TEXT_CODE_MARK_SHIFT)
176
177/// The window effect a message can start (TEXT_WINDOW_STATE): the window's
178/// frame grows by a tile and its text sprites pulse, for the channel's
179/// countdown.
180#define UI_WINDOW_EFFECT_SWELL 4
181
182/// The heap slot of the battle display's work block (struct BattleDisplayWork),
183/// whose window is the battle message window.
185
186/// The heap block the message decoder routine is copied into to run.
187#define TEXT_WORK_BLOCK 50
188
189/// The glyph transfer work in IWRAM (system/iwram.s), which icons are built in.
191
192/// Each message context bank's Huffman models and their offsets, which the
193/// message catalog built from games/tbs/text defines.
194extern const void *const Text_MessageContexts[][2];
195
196#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.
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.
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.
Small statement macros both games use for positions, velocities and bounds.
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.
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.
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 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 UiWindow_ClearTileAttributesInRect(s32 x, s32 y, u32 width, u32 height)
Marks the text tiles under a tilemap rectangle (x, y, width and height in tiles) as no longer shown,...
Definition text_tiles.c:276
The integer types, TRUE, UNUSED and the fixed-address macros.
signed int s32
Definition types.h:14
unsigned int u32
Definition types.h:15
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.
@ TEXT_SPACE
@ TEXT_PAUSE_SHORT
a 20-frame pause a button can cut short
@ TEXT_WINDOW_STATE
the next entry is the window effect to run
@ TEXT_END
@ TEXT_PAUSE_LONGEST
a 120-frame pause a button can cut short
@ TEXT_OUTLINE
the next entry is the outline colour
@ TEXT_WAIT_KEY
wait for a button, then close the window
@ TEXT_COLOURS_RESET
@ TEXT_COMMANDS
@ TEXT_VOICED_MARK
dakuten
@ TEXT_PAGE
wait for a button, then clear the window for a new page
@ TEXT_SEMIVOICED_MARK
handakuten
@ TEXT_END_ALT
@ TEXT_NEWLINE
@ TEXT_COLOUR
the next entry is the text colour
@ TEXT_LINE_SPACING
the next entry is the line spacing
@ TEXT_PAUSE_LONG
a 60-frame pause
const void *const Text_MessageContexts[][2]
Each message context bank's Huffman models and their offsets, which the message catalog built from ga...
@ HEAP_SLOT_BATTLE_DISPLAY
GlyphTransfer * gGlyphWork
The glyph transfer work in IWRAM (system/iwram.s), which icons are built in.
The options screen's work and the selection work.