src/window/window_internal.h
What every part of the window object shares: its includes, edition values, macros and the codes of decoded text. More…
#include "ability_ids.h"#include "enemy_ids.h"#include "flags.h"#include "macros.h"#include "resource_ids.h"#include "battle/battle_side.h"#include "battle/battle_state.h"#include "battle/stubs.h"#include "field/engine_stubs.h"#include "field/script.h"#include "field/particle.h"#include "game/stubs.h"#include "graphics/graphics.h"#include "menu/stubs.h"#include "shop/stubs.h"#include "window/articles.h"#include "window/glyph_arm.h"#include "window/message_reader.h"#include "window/message_speed.h"#include "window/scales.h"#include "window/select.h"#include "window/settings_menu.h"#include "window/text_font.h"#include "text/msg_ids.h"
Included by window.c.
Macros
| Name | Description | |
|---|---|---|
#define | TEXT_APPEND (entries, position, code) | Writes code at position in the ring of decoded text and steps position on, wrapping at the ring's end. |
#define | ITEM_POSSESSIVE_TEXT_COUNT SPANISH_OR(2, 4) | The possessives an item's name can take: two in Spanish, four in the other languages. |
#define | TEXT_EM_DASH_LEAD ' ' | |
#define | WINDOW_SPRITE_SPACE_WIDTH JAPANESE_OR(7, 5) | A space's width in sprite text, in pixels. |
#define | MESSAGE_COUNT 3 | WIN_STATE owns three messages, each with four line gaps. |
#define | MESSAGE_LINE_COUNT 4 | lines a page; spacing has one gap each |
#define | TEXT_DEFAULT_COLOR TEXT_COLOR_WHITE | a message's text colour at start |
#define | TEXT_DEFAULT_LINE_SPACING 10 | a message's line spacing at start |
#define | TEXT_LINE_HEIGHT 15 | pixels per text line in a fitted window |
#define | WINDOW_OPEN_TICKS 8 | Window animation lengths. |
#define | WINDOW_CLOSE_TICKS 4 | |
#define | TEXT_NUMBER_BUFFER_SIZE 16 | Scratch capacities are in bytes unless the name says halfwords. |
#define | TEXT_WIDE_STRING_BUFFER_SIZE 512 | A byte string widened to codes: 255 bytes and the terminator. |
#define | MESSAGE_NAME_HALFWORDS 24 | A name the decoder writes out into a message, decoded first into a buffer of this many halfwords. |
#define | MESSAGE_ARGUMENT_COUNT 8 | The message argument table's places. |
#define | SELECTION_MENU_ENTRY_LIMIT 16 | Entries a selection row can list. |
#define | AREA_NAME_WINDOW_TICKS 90 | How long the area's name shows. |
#define | TEXT_CODE_MARK_SHIFT 14 | The kana mark drawn with a character, in the top two bits of its code (the index into FontMarkGlyphCodes). |
#define | TEXT_CODE_VOICED (1 << TEXT_CODE_MARK_SHIFT) | |
#define | TEXT_CODE_SEMIVOICED (2 << TEXT_CODE_MARK_SHIFT) | |
#define | GLYPH_PAIR_WIDTH_MAX 15 | Outside Japanese, two narrow characters whose glyphs come to this many pixels at most are drawn together in one 16-pixel cell (mnMessageType, mnTextDrawWideStringAtOffset). |
#define | GLYPH_PAIR_OUTLINED_WIDTH_MAX 14 | As GLYPH_PAIR_WIDTH_MAX, in Spanish, in the outlined style, which widens each glyph by one. |
#define | WINDOW_ANIMATION_SWELL 4 | The window animation a message can start (TEXT_WINDOW_ANIMATION): the window's frame grows by a tile and its text sprites pulse, for the message's countdown. |
#define | BATTLE_MESSAGE_LINE_HEIGHT 13 | The pixels between a battle message's lines: the first line is 10 pixels down its canvas, the second this far below it, and the text then scrolls up a line at a time. |
#define | ICON_DIGIT_TENS_FIRST 10 | IconDigitPointers' first tens digit, 1: the digits 0 to 9 come before it. |
#define | GlyphState (*(ICON_TRANSFER **)&HeapSlots[HEAP_SLOT_ICON_TRANSFER]) | HEAP_SLOT_ICON_TRANSFER's pointer, kept in IWRAM (system/iwram.s, after WindowStateWork and PartyStatusState): the glyph transfer buffer icons are built in. |
Enumerations
| Name | Description | |
|---|---|---|
enum | anonymous enum { TEXT_END, TEXT_PAGE, TEXT_WAIT_KEY, TEXT_NEWLINE, TEXT_PAUSE … } | The control codes of decoded message text (WIN_STATE.textBuf). |
enum | SELECTION_ICON_GROUP { SELECTION_ICON_ROW, SELECTION_ICON_CHOSEN } | Which selection icon records mnSelectionMenuFindFreeIcon looks in. |
enum | TXT_STYLE { TEXT_STYLE_PLAIN, TEXT_STYLE_OUTLINED, TEXT_STYLE_WOBBLE, TE … } | The style of sprite text (WIN_STATE.outline, set by TEXT_STYLE): its glyphs outlined, or a motion of the glyph sprites (mnGlyphDraw). |
enum | anonymous enum { WINDOW_TYPING, WINDOW_TYPED } | A window's WINDOW.state while a message types into it, and once its text has ended. |
enum | anonymous enum { WINDOW_FIT_ALL_PAGES, WINDOW_FIT_GIVEN_SIZE } | How mnWindowFitOnScreen sizes a window (its flags). |
enum | ICON_FRAME { ICON_FRAME_COMMAND, ICON_FRAME_COMMAND_RED, ICON_FRAME_ITEM } | The icon frames of IconBasePointerTable (graphics/ui/marks.s) an icon is drawn over. |
enum | ICON_MARK { ICON_MARK_EQUIPPED, ICON_MARK_BROKEN, ICON_MARK_CURSED } | The marks of IconMarkPointers drawn over an item's icon. |
enum | anonymous enum { SPRITE_AFFINE_OFF, SPRITE_AFFINE_ON, SPRITE_AFFINE_DOUBLE_SI … } | A sprite cell's affine field (OAM attribute 0's bits 8 and 9) and its shape field, as the window and selection sprites set them. |
enum | anonymous enum { SPRITE_SHAPE_SQUARE, SPRITE_SHAPE_WIDE, SPRITE_SHAPE_TALL } |
Functions
| Name | Description | |
|---|---|---|
void | mnWindowPutGlyph ( WINDOW *window, Uint32 tile, Uint32 x, Uint32 y, Sint32 mode) | The window code calls these before any declaration of them. |
void | mnWindowClearTextTilesInRect (Sint32 x, Sint32 y, Uint32 width, Uint32 height) | Frees the text tiles under a tilemap rectangle (x, y, width and height in tiles) for reuse: their taken and shown bits are cleared. |
Variables
| Name | Description | |
|---|---|---|
extern const void *const | TextMessageContexts [][2] | Each message context bank's Huffman models and their offsets, which the message catalog built from games/tbs/text defines. |
Description
What every part of the window object shares: its includes, edition values,
macros and the codes of decoded text. window.c includes it before the parts,
and each part includes it too, so that a part read on its own still resolves.
Macros in detail
TEXT_APPEND
#define TEXT_APPEND(entries, position, code)
Writes code at position in the ring of decoded text and steps position on, wrapping at the ring's end.
Referenced by mnMessageAppendArticleName() and mnMessageDecode().
Definition at line 35 of file window_internal.h.
ITEM_POSSESSIVE_TEXT_COUNT
#define ITEM_POSSESSIVE_TEXT_COUNT SPANISH_OR(2, 4)
The possessives an item's name can take: two in Spanish, four in the other languages.
Definition at line 41 of file window_internal.h.
TEXT_EM_DASH_LEAD
#define TEXT_EM_DASH_LEAD ' '
#define TEXT_EM_DASH_LEAD 143
Referenced by mnMessageDecode().
Definition at lines 49 and 51 of file window_internal.h.
WINDOW_SPRITE_SPACE_WIDTH
#define WINDOW_SPRITE_SPACE_WIDTH JAPANESE_OR(7, 5)
A space's width in sprite text, in pixels.
Referenced by mnGlyphDraw(), mnTextMeasureAllPages() and mnTextMeasureDecoded().
Definition at line 55 of file window_internal.h.
MESSAGE_COUNT
#define MESSAGE_COUNT 3
WIN_STATE owns three messages, each with four line gaps.
Referenced by mnBattleMessageContinue(), mnMessageAllTyped(), mnMessageResetIdle(), mnMessageStart() and mnMessageUpdateAll().
Definition at line 68 of file window_internal.h.
MESSAGE_LINE_COUNT
#define MESSAGE_LINE_COUNT 4
lines a page; spacing has one gap each
Referenced by mnBattleMessageContinue(), mnMessageStart(), mnMessageType(), mnTextMeasureAllPages() and mnTextMeasureDecoded().
Definition at line 69 of file window_internal.h.
TEXT_DEFAULT_COLOR
#define TEXT_DEFAULT_COLOR TEXT_COLOR_WHITE
a message's text colour at start
Referenced by mnBattleMessageContinue(), mnMessageResetIdle(), mnMessageStart(), mnMessageType(), mnTextDrawStringAsTiles(), mnTextResetStyle(), mnWindowSystemStartBattleUpdate() and mnWindowSystemStartFieldUpdate().
Definition at line 70 of file window_internal.h.
TEXT_DEFAULT_LINE_SPACING
#define TEXT_DEFAULT_LINE_SPACING 10
a message's line spacing at start
Referenced by mnBattleMessageContinue(), mnMessageAppendArticleName(), mnMessageResetIdle(), mnMessageStart(), mnMessageType(), mnTextResetStyle(), mnWindowSystemStartBattleUpdate() and mnWindowSystemStartFieldUpdate().
Definition at line 71 of file window_internal.h.
TEXT_LINE_HEIGHT
#define TEXT_LINE_HEIGHT 15
pixels per text line in a fitted window
Referenced by mnMessageType(), mnTextDrawWideStringAtOffset(), mnTextMeasureAllPages() and mnTextMeasureDecoded().
Definition at line 72 of file window_internal.h.
WINDOW_OPEN_TICKS
#define WINDOW_OPEN_TICKS 8
Window animation lengths.
Referenced by mnWindowCreate().
Definition at line 75 of file window_internal.h.
WINDOW_CLOSE_TICKS
#define WINDOW_CLOSE_TICKS 4
Referenced by mnWindowClose().
Definition at line 76 of file window_internal.h.
TEXT_NUMBER_BUFFER_SIZE
#define TEXT_NUMBER_BUFFER_SIZE 16
Scratch capacities are in bytes unless the name says halfwords.
mnStringFormatNumber writes 14 of them.
Referenced by mnMessageDecode(), mnTextDrawNumber(), mnTextDrawNumberAtOffset(), mnTextDrawNumberInWindow() and mnTextDrawPrefixedNumberAtOffset().
Definition at line 80 of file window_internal.h.
TEXT_WIDE_STRING_BUFFER_SIZE
#define TEXT_WIDE_STRING_BUFFER_SIZE 512
A byte string widened to codes: 255 bytes and the terminator.
Referenced by mnTextDrawString(), mnTextDrawStringAtOffset() and mnTextDrawStringInWindow().
Definition at line 82 of file window_internal.h.
MESSAGE_NAME_HALFWORDS
#define MESSAGE_NAME_HALFWORDS 24
A name the decoder writes out into a message, decoded first into a buffer of this many halfwords.
Referenced by mnMessageDecode().
Definition at line 85 of file window_internal.h.
MESSAGE_ARGUMENT_COUNT
#define MESSAGE_ARGUMENT_COUNT 8
The message argument table's places.
Referenced by mnMessageArgumentClearAll(), mnMessageArgumentLookup() and mnMessageArgumentPush().
Definition at line 87 of file window_internal.h.
SELECTION_MENU_ENTRY_LIMIT
#define SELECTION_MENU_ENTRY_LIMIT 16
Entries a selection row can list.
Referenced by mnSelectionMenuAddEntry().
Definition at line 89 of file window_internal.h.
AREA_NAME_WINDOW_TICKS
#define AREA_NAME_WINDOW_TICKS 90
How long the area's name shows.
Referenced by mnAreaNameWindowShow().
Definition at line 91 of file window_internal.h.
TEXT_CODE_MARK_SHIFT
#define TEXT_CODE_MARK_SHIFT 14
The kana mark drawn with a character, in the top two bits of its code (the
index into FontMarkGlyphCodes).
Referenced by mnGlyphDraw() and mnTextDrawGlyphPair().
Definition at line 165 of file window_internal.h.
TEXT_CODE_VOICED
#define TEXT_CODE_VOICED (1 << TEXT_CODE_MARK_SHIFT)
Referenced by mnMessageType().
Definition at line 166 of file window_internal.h.
TEXT_CODE_SEMIVOICED
#define TEXT_CODE_SEMIVOICED (2 << TEXT_CODE_MARK_SHIFT)
Referenced by mnMessageType().
Definition at line 167 of file window_internal.h.
GLYPH_PAIR_WIDTH_MAX
#define GLYPH_PAIR_WIDTH_MAX 15
Outside Japanese, two narrow characters whose glyphs come to this many pixels
at most are drawn together in one 16-pixel cell (mnMessageType,
mnTextDrawWideStringAtOffset).
Referenced by mnMessageType() and mnTextDrawWideStringAtOffset().
Definition at line 191 of file window_internal.h.
GLYPH_PAIR_OUTLINED_WIDTH_MAX
#define GLYPH_PAIR_OUTLINED_WIDTH_MAX 14
As GLYPH_PAIR_WIDTH_MAX, in Spanish, in the outlined style, which widens each
glyph by one.
Referenced by mnMessageType() and mnTextDrawWideStringAtOffset().
Definition at line 194 of file window_internal.h.
WINDOW_ANIMATION_SWELL
#define WINDOW_ANIMATION_SWELL 4
The window animation a message can start (TEXT_WINDOW_ANIMATION): the
window's frame grows by a tile and its text sprites pulse, for the message's
countdown.
Referenced by mnWindowSpriteUpdateAll() and mnWindowStepSwellEffect().
Definition at line 199 of file window_internal.h.
BATTLE_MESSAGE_LINE_HEIGHT
#define BATTLE_MESSAGE_LINE_HEIGHT 13
The pixels between a battle message's lines: the first line is 10 pixels down its canvas, the second this far below it, and the text then scrolls up a line at a time.
Referenced by mnBattleMessageContinue() and mnMessageType().
Definition at line 212 of file window_internal.h.
ICON_DIGIT_TENS_FIRST
#define ICON_DIGIT_TENS_FIRST 10
IconDigitPointers' first tens digit, 1: the digits 0 to 9 come before it.
Referenced by mnItemIconCompose().
Definition at line 242 of file window_internal.h.
GlyphState
#define GlyphState (*(ICON_TRANSFER **)&HeapSlots[HEAP_SLOT_ICON_TRANSFER])
HEAP_SLOT_ICON_TRANSFER's pointer, kept in IWRAM (system/iwram.s, after
WindowStateWork and PartyStatusState): the glyph transfer buffer icons are
built in. Each icon builder allocates the slot for its build and frees it
after.
Referenced by mnIconDrawItem(), mnIconDrawMiscellaneous() and mnItemIconCompose().
Definition at line 267 of file window_internal.h.
Enumerations in detail
anonymous enum
enum { TEXT_END, TEXT_PAGE, TEXT_WAIT_KEY, TEXT_NEWLINE, … }
The control codes of decoded message text (WIN_STATE.textBuf). Codes from
TEXT_SPACE up are characters.
| Enumerator | Value | Description |
|---|---|---|
TEXT_END | 0 | The text ends; the window stays open. |
TEXT_PAGE | 1 | Wait for a button, then clear the window for a new page. |
TEXT_WAIT_KEY | 2 | Wait for a button, then close the |
TEXT_NEWLINE | 3 | window. |
TEXT_PAUSE_LONG | 4 | A 60-tick pause. |
TEXT_PAUSE_SHORT | 5 | A 20-tick pause a button can cut short. |
TEXT_PAUSE_LONGEST | 6 | A 120-tick pause a button can cut short. |
TEXT_RESET_STYLE | 7 | TEXT_DEFAULT_COLOR, TEXT_STYLE_PLAIN and TEXT_DEFAULT_LINE_SPACING again (the catalogs' reset_text_style). |
TEXT_COLOR | 8 | The next entry is the text colour. |
TEXT_STYLE | 9 | The next entry is the text style (TXT_STYLE). |
TEXT_LINE_SPACING | 10 | The next entry is the line spacing; a glyph sprite sits half of it below its line's top. |
TEXT_UNUSED_11 | 11 | Open question (no evidence in reach): what codes 11 and 12 (one operand) and 14 (two) are for, which drawing and measuring skip with their operands; no message of The Broken Seal uses them and neither game's decoder names them, so nothing the game shows settles it. |
TEXT_UNUSED_12 | 12 | |
TEXT_UNUSED_14 | 14 | |
TEXT_WINDOW_ANIMATION | 15 | The next entry is the window animation to run. |
TEXT_ACTOR_NAME | 17 | MESSAGE_ACTOR_NAME as mnMessageDecodeRaw keeps it, unexpanded: the next entry names the unit, and drawing and measuring skip both. |
TEXT_ACTOR_NAME_START | 28 | The first letters of a unit's name, a stammer, as The Lost Age's decoder writes its MESSAGE_ACTOR_NAME_START: the next two entries are the unit and how many letters, and drawing and measuring skip all three, as The Lost Age's do. No message of The Broken Seal uses it. |
TEXT_ARTICLE_CLASS | 29 | MESSAGE_ARTICLE_CLASS as mnMessageDecodeRaw keeps it outside Japanese, at the head of an item or class name: drawing skips it and its class. |
TEXT_END_ALT | 30 | Ends the text as TEXT_END does. |
TEXT_COMMANDS | 31 | The message runs the codes below it |
TEXT_SPACE | 32 | as control codes and draws the rest. |
TEXT_OPENING_QUOTE | 142 | “, outside Japanese. |
TEXT_INVERTED_EXCLAMATION_MARK | 161 | ¡, outside Japanese. |
TEXT_JAPANESE_FULL_STOP | 161 | 。 |
TEXT_JAPANESE_COMMA | 164 | 、 |
TEXT_JAPANESE_MIDDLE_DOT | 165 | ・ |
TEXT_INVERTED_QUESTION_MARK | 191 | ¿, outside Japanese. |
Definition at line 95 of file window_internal.h.
SELECTION_ICON_GROUP
enum SELECTION_ICON_GROUP
Which selection icon records mnSelectionMenuFindFreeIcon looks in.
| Enumerator | Value | Description |
|---|---|---|
SELECTION_ICON_ROW | 0 | the seven icons of the row |
SELECTION_ICON_CHOSEN | 1 | the five icons already chosen; any nonzero |
Definition at line 170 of file window_internal.h.
TXT_STYLE
enum TXT_STYLE
The style of sprite text (WIN_STATE.outline, set by TEXT_STYLE): its glyphs
outlined, or a motion of the glyph sprites (mnGlyphDraw).
| Enumerator | Value | Description |
|---|---|---|
TEXT_STYLE_PLAIN | 0 | |
TEXT_STYLE_OUTLINED | 1 | drawn a pixel wider (mnTextDrawGlyphPair) |
TEXT_STYLE_WOBBLE | 2 | WINDOW_SPRITE_MOTION_WOBBLE |
TEXT_STYLE_SHAKE | 3 | WINDOW_SPRITE_MOTION_SHAKE |
TEXT_STYLE_POP | 4 | WINDOW_SPRITE_MOTION_POP |
TEXT_STYLE_SPIN | 5 | WINDOW_SPRITE_MOTION_SPIN, a pixel wider too |
Definition at line 178 of file window_internal.h.
anonymous enum
enum { WINDOW_TYPING, WINDOW_TYPED }
A window's WINDOW.state while a message types into it, and once its text has
ended.
| Enumerator | Value | Description |
|---|---|---|
WINDOW_TYPING | 0 | |
WINDOW_TYPED | 1 |
Definition at line 203 of file window_internal.h.
anonymous enum
enum { WINDOW_FIT_ALL_PAGES, WINDOW_FIT_GIVEN_SIZE }
How mnWindowFitOnScreen sizes a window (its flags).
| Enumerator | Value | Description |
|---|---|---|
WINDOW_FIT_ALL_PAGES | 1 | Measure every page and take the widest and tallest (mnTextMeasureAllPages) rather than the first page alone. |
WINDOW_FIT_GIVEN_SIZE | 2 | Take the width and height given, in tiles, instead of measuring. |
Definition at line 215 of file window_internal.h.
ICON_FRAME
enum ICON_FRAME
The icon frames of IconBasePointerTable (graphics/ui/marks.s) an icon is
drawn over.
| Enumerator | Value | Description |
|---|---|---|
ICON_FRAME_COMMAND | 0 | |
ICON_FRAME_COMMAND_RED | 1 | |
ICON_FRAME_ITEM | 2 | under items and Psynergy alike |
Definition at line 226 of file window_internal.h.
ICON_MARK
enum ICON_MARK
The marks of IconMarkPointers drawn over an item's icon.
| Enumerator | Value | Description |
|---|---|---|
ICON_MARK_EQUIPPED | 0 | the green E of an equipped item |
ICON_MARK_BROKEN | 1 | the red cross |
ICON_MARK_CURSED | 2 | the white skull of a cursed item worn |
Definition at line 234 of file window_internal.h.
anonymous enum
enum { SPRITE_AFFINE_OFF, SPRITE_AFFINE_ON, SPRITE_AFFINE_DOUBLE_SIZE }
A sprite cell's affine field (OAM attribute 0's bits 8 and 9) and its shape field, as the window and selection sprites set them.
| Enumerator | Value | Description |
|---|---|---|
SPRITE_AFFINE_OFF | 0 | |
SPRITE_AFFINE_ON | 1 | |
SPRITE_AFFINE_DOUBLE_SIZE | 3 | Affine in a box twice its size: the sprite stands 8 pixels up and left of its plain place for a 16x16 sprite, 16 for a 32x32 one. |
Definition at line 246 of file window_internal.h.
anonymous enum
enum { SPRITE_SHAPE_SQUARE, SPRITE_SHAPE_WIDE, SPRITE_SHAPE_TALL }
| Enumerator | Value | Description |
|---|---|---|
SPRITE_SHAPE_SQUARE | 0 | size 0 is 8x8, 1 16x16, 2 32x32 |
SPRITE_SHAPE_WIDE | 1 | |
SPRITE_SHAPE_TALL | 2 | size 0 is 8x16 |
Definition at line 256 of file window_internal.h.
Variables in detail
TextMessageContexts
extern const void *const TextMessageContexts[][2]
Each message context bank's Huffman models and their offsets, which the message catalog built from games/tbs/text defines.
Referenced by mnTextDecodeSymbolInC().
Definition at line 271 of file window_internal.h.