Skip to Content
The Alchemy Project

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…

Included by window.c.

Macros

NameDescription
#defineTEXT_APPEND (entries, position, code)Writes code at position in the ring of decoded text and steps position on, wrapping at the ring's end.
#defineITEM_POSSESSIVE_TEXT_COUNT SPANISH_OR(2, 4)The possessives an item's name can take: two in Spanish, four in the other languages.
#defineTEXT_EM_DASH_LEAD ' '
#defineWINDOW_SPRITE_SPACE_WIDTH JAPANESE_OR(7, 5)A space's width in sprite text, in pixels.
#defineMESSAGE_COUNT 3WIN_STATE owns three messages, each with four line gaps.
#defineMESSAGE_LINE_COUNT 4lines a page; spacing has one gap each
#defineTEXT_DEFAULT_COLOR TEXT_COLOR_WHITEa message's text colour at start
#defineTEXT_DEFAULT_LINE_SPACING 10a message's line spacing at start
#defineTEXT_LINE_HEIGHT 15pixels per text line in a fitted window
#defineWINDOW_OPEN_TICKS 8Window animation lengths.
#defineWINDOW_CLOSE_TICKS 4
#defineTEXT_NUMBER_BUFFER_SIZE 16Scratch capacities are in bytes unless the name says halfwords.
#defineTEXT_WIDE_STRING_BUFFER_SIZE 512A byte string widened to codes: 255 bytes and the terminator.
#defineMESSAGE_NAME_HALFWORDS 24A name the decoder writes out into a message, decoded first into a buffer of this many halfwords.
#defineMESSAGE_ARGUMENT_COUNT 8The message argument table's places.
#defineSELECTION_MENU_ENTRY_LIMIT 16Entries a selection row can list.
#defineAREA_NAME_WINDOW_TICKS 90How long the area's name shows.
#defineTEXT_CODE_MARK_SHIFT 14The kana mark drawn with a character, in the top two bits of its code (the index into FontMarkGlyphCodes).
#defineTEXT_CODE_VOICED (1 << TEXT_CODE_MARK_SHIFT)
#defineTEXT_CODE_SEMIVOICED (2 << TEXT_CODE_MARK_SHIFT)
#defineGLYPH_PAIR_WIDTH_MAX 15Outside Japanese, two narrow characters whose glyphs come to this many pixels at most are drawn together in one 16-pixel cell (mnMessageType, mnTextDrawWideStringAtOffset).
#defineGLYPH_PAIR_OUTLINED_WIDTH_MAX 14As GLYPH_PAIR_WIDTH_MAX, in Spanish, in the outlined style, which widens each glyph by one.
#defineWINDOW_ANIMATION_SWELL 4The 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.
#defineBATTLE_MESSAGE_LINE_HEIGHT 13The 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.
#defineICON_DIGIT_TENS_FIRST 10IconDigitPointers' first tens digit, 1: the digits 0 to 9 come before it.
#defineGlyphState (*(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

NameDescription
enumanonymous enum { TEXT_END, TEXT_PAGE, TEXT_WAIT_KEY, TEXT_NEWLINE, TEXT_PAUSE … }The control codes of decoded message text (WIN_STATE.textBuf).
enumSELECTION_ICON_GROUP { SELECTION_ICON_ROW, SELECTION_ICON_CHOSEN }Which selection icon records mnSelectionMenuFindFreeIcon looks in.
enumTXT_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).
enumanonymous enum { WINDOW_TYPING, WINDOW_TYPED }A window's WINDOW.state while a message types into it, and once its text has ended.
enumanonymous enum { WINDOW_FIT_ALL_PAGES, WINDOW_FIT_GIVEN_SIZE }How mnWindowFitOnScreen sizes a window (its flags).
enumICON_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.
enumICON_MARK { ICON_MARK_EQUIPPED, ICON_MARK_BROKEN, ICON_MARK_CURSED }The marks of IconMarkPointers drawn over an item's icon.
enumanonymous 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.
enumanonymous enum { SPRITE_SHAPE_SQUARE, SPRITE_SHAPE_WIDE, SPRITE_SHAPE_TALL }

Functions

NameDescription
voidmnWindowPutGlyph ( WINDOW *window, Uint32 tile, Uint32 x, Uint32 y, Sint32 mode)The window code calls these before any declaration of them.
voidmnWindowClearTextTilesInRect (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

NameDescription
extern const void *constTextMessageContexts [][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.

EnumeratorValueDescription
TEXT_END0The text ends; the window stays open.
TEXT_PAGE1Wait for a button, then clear the window for a new page.
TEXT_WAIT_KEY2Wait for a button, then close the
TEXT_NEWLINE3window.
TEXT_PAUSE_LONG4A 60-tick pause.
TEXT_PAUSE_SHORT5A 20-tick pause a button can cut short.
TEXT_PAUSE_LONGEST6A 120-tick pause a button can cut short.
TEXT_RESET_STYLE7TEXT_DEFAULT_COLOR, TEXT_STYLE_PLAIN and TEXT_DEFAULT_LINE_SPACING again (the catalogs' reset_text_style).
TEXT_COLOR8The next entry is the text colour.
TEXT_STYLE9The next entry is the text style (TXT_STYLE).
TEXT_LINE_SPACING10The next entry is the line spacing; a glyph sprite sits half of it below its line's top.
TEXT_UNUSED_1111Open 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_1212
TEXT_UNUSED_1414
TEXT_WINDOW_ANIMATION15The next entry is the window animation to run.
TEXT_ACTOR_NAME17MESSAGE_ACTOR_NAME as mnMessageDecodeRaw keeps it, unexpanded: the next entry names the unit, and drawing and measuring skip both.
TEXT_ACTOR_NAME_START28The 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_CLASS29MESSAGE_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_ALT30Ends the text as TEXT_END does.
TEXT_COMMANDS31The message runs the codes below it
TEXT_SPACE32as control codes and draws the rest.
TEXT_OPENING_QUOTE142“, outside Japanese.
TEXT_INVERTED_EXCLAMATION_MARK161¡, outside Japanese.
TEXT_JAPANESE_FULL_STOP161。
TEXT_JAPANESE_COMMA164、
TEXT_JAPANESE_MIDDLE_DOT165・
TEXT_INVERTED_QUESTION_MARK191¿, 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.

EnumeratorValueDescription
SELECTION_ICON_ROW0the seven icons of the row
SELECTION_ICON_CHOSEN1the 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).

EnumeratorValueDescription
TEXT_STYLE_PLAIN0
TEXT_STYLE_OUTLINED1drawn a pixel wider (mnTextDrawGlyphPair)
TEXT_STYLE_WOBBLE2WINDOW_SPRITE_MOTION_WOBBLE
TEXT_STYLE_SHAKE3WINDOW_SPRITE_MOTION_SHAKE
TEXT_STYLE_POP4WINDOW_SPRITE_MOTION_POP
TEXT_STYLE_SPIN5WINDOW_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.

EnumeratorValueDescription
WINDOW_TYPING0
WINDOW_TYPED1

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).

EnumeratorValueDescription
WINDOW_FIT_ALL_PAGES1Measure every page and take the widest and tallest (mnTextMeasureAllPages) rather than the first page alone.
WINDOW_FIT_GIVEN_SIZE2Take 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.

EnumeratorValueDescription
ICON_FRAME_COMMAND0
ICON_FRAME_COMMAND_RED1
ICON_FRAME_ITEM2under 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.

EnumeratorValueDescription
ICON_MARK_EQUIPPED0the green E of an equipped item
ICON_MARK_BROKEN1the red cross
ICON_MARK_CURSED2the 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.

EnumeratorValueDescription
SPRITE_AFFINE_OFF0
SPRITE_AFFINE_ON1
SPRITE_AFFINE_DOUBLE_SIZE3Affine 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 }

EnumeratorValueDescription
SPRITE_SHAPE_SQUARE0size 0 is 8x8, 1 16x16, 2 32x32
SPRITE_SHAPE_WIDE1
SPRITE_SHAPE_TALL2size 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.