Skip to Content
The Alchemy Project

src/window/window_decode.c

The message decoder: a stored message expanded into the ring of decoded text, its arguments, names and numbers written out, and outside Japanese the articles, plurals and possessives each language puts around them. More…

Included by window.c.

Structures

NameDescription
structARTICLE_TABLEThe article strings of one language, by kind, copied whole (articles.c).
structDE_ARTICLESThe German "de" articles, elided and whole, copied whole (articles.c).
structPOSSESSIVE_TABLEThe possessive endings, by kind, copied whole (articles.c).

Macros

NameDescription
#defineARTICLE_KINDS BY_LANGUAGE(8, 8, 8, 5, 8, 11)The number of article kinds in each edition's table (articles.c), and the mask a name's kind is read through.
#defineARTICLE_KIND_MASK SPANISH_OR(15, 7)
#defineENTRY_NARROW_GAP TEXT_PAUSE_SHORTWhat the decode flags of mnMessageSetDecodeFlags put between characters.
#defineENTRY_WIDE_GAP TEXT_MARK_VOICEDWith spacingAfter (English and Japanese): TEXT_MARK_VOICED after a character of codes WIDE_GAP_FIRST to WIDE_GAP_LAST, other than the kana marks and the Japanese full stop, comma and middle dot.
#defineWIDE_GAP_FIRST 128The codes a wide gap follows: the Japanese font's upper half, codes 128 to 255, its kana (from を, code 0x86), to 256, its first kanji (神, charmap_ja.tsv).
#defineWIDE_GAP_LAST 256
#defineHALTING_SPEECH_LENGTH 10Halting speech breaks off with three dots at a space, or after this many codes.
#defineOPERAND_UNBIAS ((Uint32)(Uint16)-1)An operand is stored one more than its value, so that none is 0, the end code; adding this takes the one off in the halfword written.
#defineMYSTERY_NAME_CAPACITY 10The Mystery Man's or Woman's name is decoded into ten halfwords, the end code's included.
#definePOSSESSIVE_MAX_LETTERS 16A possessive word is copied up to its sixteenth letter.
#defineBUTTON_ICON_FIRST_CODE 128MESSAGE_BUTTON_ICON's first character code: a button's two characters are codes BUTTON_ICON_FIRST_CODE + 2 * n and the next.
#definePLURAL_ITEM_NAMES_OFFSET 461The European editions keep a second item name table after the first, read for the plural forms; its distance from MsgItemName is a message id.
#defineSUFFIX_START BY_LANGUAGE(0, 0, 2, 2, 2, 2)What suffix starts as: the European editions use 2 to capitalize the first letter of a sentence.
#definePOSSESSIVE_COUNT SPANISH_OR(2, 4)The possessives (articles.c), copied whole: Spanish {singular, plural}, German and Italian one for each item gender (LocalizedWordItemGenders).
#defineMYSTERY_MAN_MESSAGE ((Sint32)MsgWaitingForOpponent + 1)なぞの男 ("Mystery Man"), the message after MsgWaitingForOpponent; なぞの女 ("Mystery Woman") follows it.

Enumerations

NameDescription
enumanonymous enum { MESSAGE_END, MESSAGE_PAGE_BREAK, MESSAGE_END_WAIT, MESSAGE_L … }The control codes of a message as stored (the PO catalogs' names), which mnMessageDecode expands into decoded text.
enumARTICLE_FORM { ARTICLE_FORM_BARE, ARTICLE_FORM_ARTICLE, ARTICLE_FORM_PLURAL … }The operand of an item, class or name code: how its name is written.
enumanonymous enum { ARTICLE_A, ARTICLE_AN }The English articles (articles.c) a name with no article class takes.

Functions

NameDescription
Uint32mnMessageAppendArticleName (Sint32 mode, Uint16 *name, Uint32 writePos, Uint16 *entries, Sint32 articleForm, Sint32 plural, Sint32 *suffix)Copies a name into the decoded text at writePos and returns the position after it: with its article in front (ARTICLE_FORM_ARTICLE, or ARTICLE_FORM_BY_COUNT for one) and an s or es after it (ARTICLE_FORM_PLURAL, or ARTICLE_FORM_BY_COUNT for several).
Uint32mnMessageArgumentLookup (Uint32 name, Uint32 clear)Returns the value of the first message argument of kind (MESSAGE_ARGUMENT_), or 0 when there is none.
Uint8 *mnStringFormatNumber (Uint8 *buf, Sint32 input, Sint32 width)Writes input as decimal text into buf (NUMBER_DIGITS + 2 bytes) and returns where the text starts.
Sint32mnMessageDecode (Sint32 msg, Sint32 clear)Decodes message into the ring of decoded text (WIN_STATE.textBuf) after the text decoded last, and returns where it starts; message -1 returns the last decoded message's start again.

Variables

NameDescription
extern const struct DE_ARTICLESTextDeArticles"de", elided and whole.
extern const Uint8TextDecodeSymbolCode []The symbol decoder RAM_CODE_LOAD copies to RAM to run, and its size, as this symbol's address.
extern Uint8TextDecodeSymbolCodeSize []
extern Uint8MsgClassName [], MsgItemName[], MsgAbilityName[], MsgDebugAreaName[]
extern const Sint8LocalizedWordItemPronoun []
extern const struct POSSESSIVE_TABLELocalizedWordItemPossessivesThe possessive ("your") for each item gender (LocalizedWordItemGenders).
extern const Sint8LocalizedWordItemGenders []Each item's gender, by item id.
extern const Uint8 *constLocalizedWordCountedNouns []{singular, plural}: window.c reads [(kind & 7) * 2 + plural].
extern Uint8MsgWaitingForOpponent []

Description

The message decoder: a stored message expanded into the ring of decoded text, its arguments, names and numbers written out, and outside Japanese the articles, plurals and possessives each language puts around them. Part of window.c.

Macros in detail

ARTICLE_KINDS

#define ARTICLE_KINDS BY_LANGUAGE(8, 8, 8, 5, 8, 11)

The number of article kinds in each edition's table (articles.c), and the mask a name's kind is read through.

Definition at line 8 of file window_decode.c.

ARTICLE_KIND_MASK

#define ARTICLE_KIND_MASK SPANISH_OR(15, 7)

Referenced by mnMessageAppendArticleName().

Definition at line 9 of file window_decode.c.

ENTRY_NARROW_GAP

#define ENTRY_NARROW_GAP TEXT_PAUSE_SHORT

What the decode flags of mnMessageSetDecodeFlags put between characters.

Referenced by mnMessageDecode().

Definition at line 100 of file window_decode.c.

ENTRY_WIDE_GAP

#define ENTRY_WIDE_GAP TEXT_MARK_VOICED

With spacingAfter (English and Japanese): TEXT_MARK_VOICED after a character of codes WIDE_GAP_FIRST to WIDE_GAP_LAST, other than the kana marks and the Japanese full stop, comma and middle dot.

Referenced by mnMessageDecode().

Definition at line 104 of file window_decode.c.

WIDE_GAP_FIRST

#define WIDE_GAP_FIRST 128

The codes a wide gap follows: the Japanese font's upper half, codes 128 to 255, its kana (from を, code 0x86), to 256, its first kanji (神, charmap_ja.tsv).

Referenced by mnMessageDecode().

Definition at line 108 of file window_decode.c.

WIDE_GAP_LAST

#define WIDE_GAP_LAST 256

Referenced by mnMessageDecode().

Definition at line 109 of file window_decode.c.

HALTING_SPEECH_LENGTH

#define HALTING_SPEECH_LENGTH 10

Halting speech breaks off with three dots at a space, or after this many codes.

Referenced by mnMessageDecode().

Definition at line 112 of file window_decode.c.

OPERAND_UNBIAS

#define OPERAND_UNBIAS ((Uint32)(Uint16)-1)

An operand is stored one more than its value, so that none is 0, the end code; adding this takes the one off in the halfword written.

Referenced by mnMessageDecode() and mnMessageDecodeRaw().

Definition at line 115 of file window_decode.c.

MYSTERY_NAME_CAPACITY

#define MYSTERY_NAME_CAPACITY 10

The Mystery Man's or Woman's name is decoded into ten halfwords, the end code's included.

Referenced by mnMessageDecode().

Definition at line 118 of file window_decode.c.

POSSESSIVE_MAX_LETTERS

#define POSSESSIVE_MAX_LETTERS 16

A possessive word is copied up to its sixteenth letter.

Referenced by mnMessageDecode().

Definition at line 120 of file window_decode.c.

BUTTON_ICON_FIRST_CODE

#define BUTTON_ICON_FIRST_CODE 128

MESSAGE_BUTTON_ICON's first character code: a button's two characters are codes BUTTON_ICON_FIRST_CODE + 2 * n and the next.

Referenced by mnMessageDecode().

Definition at line 123 of file window_decode.c.

PLURAL_ITEM_NAMES_OFFSET

#define PLURAL_ITEM_NAMES_OFFSET 461

The European editions keep a second item name table after the first, read for the plural forms; its distance from MsgItemName is a message id.

Referenced by mnMessageDecode().

Definition at line 370 of file window_decode.c.

SUFFIX_START

#define SUFFIX_START BY_LANGUAGE(0, 0, 2, 2, 2, 2)

What suffix starts as: the European editions use 2 to capitalize the first letter of a sentence.

Referenced by mnMessageDecode().

Definition at line 374 of file window_decode.c.

POSSESSIVE_COUNT

#define POSSESSIVE_COUNT SPANISH_OR(2, 4)

The possessives (articles.c), copied whole: Spanish {singular, plural}, German and Italian one for each item gender (LocalizedWordItemGenders).

Definition at line 390 of file window_decode.c.

MYSTERY_MAN_MESSAGE

#define MYSTERY_MAN_MESSAGE ((Sint32)MsgWaitingForOpponent + 1)

なぞの男 ("Mystery Man"), the message after MsgWaitingForOpponent; なぞの女 ("Mystery Woman") follows it.

Referenced by mnMessageDecode().

Definition at line 1029 of file window_decode.c.

Enumerations in detail

anonymous enum

enum { MESSAGE_END, MESSAGE_PAGE_BREAK, MESSAGE_END_WAIT, MESSAGE_LINE_BREAK, … }

The control codes of a message as stored (the PO catalogs' names), which mnMessageDecode expands into decoded text.

EnumeratorValueDescription
MESSAGE_END0Kept as TEXT_END: the window stays open.
MESSAGE_PAGE_BREAK1Kept as TEXT_PAGE.
MESSAGE_END_WAIT2Kept as TEXT_WAIT_KEY: a button closes the window.
MESSAGE_LINE_BREAK3Kept as TEXT_NEWLINE.
MESSAGE_TEXT_COLOR8Kept with its operand as TEXT_COLOR.
MESSAGE_TEXT_EFFECT9Kept with its operand as TEXT_OUTLINE.
MESSAGE_LINE_SPACING10Kept with its operand as TEXT_LINE_SPACING.
MESSAGE_UNUSED_1111Kept with its operand as TEXT_UNUSED_11.
MESSAGE_UNUSED_1212Kept with its operand as TEXT_UNUSED_12.
MESSAGE_LOCALIZED_WORD13German: a counted noun; Italian: a gender ending; Spanish and French: the plural suffix
MESSAGE_UNUSED_1414Kept with its two operands as TEXT_UNUSED_14.
MESSAGE_WINDOW_EFFECT15Kept with its operand as TEXT_WINDOW_ANIMATION: the window animation to run.
MESSAGE_PROTAGONIST_NAME16The name of the unit MainRoutineStateWork.leaderActorId names.
MESSAGE_ACTOR_NAME17The name of the unit its operand names.
MESSAGE_ARGUMENT_ACTOR_NAME18The argument codes write out the next message argument of their kind (MESSAGE_ARGUMENT_).
MESSAGE_ARGUMENT_CLASS_NAME19
MESSAGE_ARGUMENT_ITEM_NAME20
MESSAGE_ARGUMENT_ABILITY_NAME21
MESSAGE_ARGUMENT_SIGNED_NUMBER22The number argument, with a minus
MESSAGE_ARGUMENT_LOCATION_NAME23sign when negative; outside Japanese any number but -1, 0 and 1 makes what follows plural.
MESSAGE_PLURAL_SUFFIX25English: the plural suffix; German, Spanish, French and Italian: the item's possessive
MESSAGE_BUTTON_ICON26A button drawn as two characters, codes BUTTON_ICON_FIRST_CODE + 2 * n and the next for operand value n.
MESSAGE_POSSESSIVE_SUFFIX27English: an apostrophe, and an s unless the name ended in s; German: an apostrophe after s or z, else an s; nothing in Spanish, French and Italian.
MESSAGE_ACTOR_NAME_START28The first letters of a unit's name, a stammer: its operands are the unit and how many letters (a kana keeps its mark).
MESSAGE_ARTICLE_CLASS29The article class of the name it starts, in item and class names, which mnMessageAppendArticleName reads and drops.
MESSAGE_END_NOW30Kept as TEXT_END_ALT, which the message ends as it ends TEXT_END.
MESSAGE_EM_DASH176The em dash, stored as the character ° rather than The Broken Seal's code 24: TEXT_ARGUMENT_SPACE and a hyphen, and outside English a space after. The Japanese decoder keeps it as it is.

Definition at line 29 of file window_decode.c.

ARTICLE_FORM

enum ARTICLE_FORM

The operand of an item, class or name code: how its name is written.

EnumeratorValueDescription
ARTICLE_FORM_BARE0The name alone.
ARTICLE_FORM_ARTICLE1With its article in front.
ARTICLE_FORM_PLURAL2English: the plural ending after it; elsewhere the article, and for an item its plural name
ARTICLE_FORM_BY_COUNT3The article while the last number was -1, 0 or 1, else as ARTICLE_FORM_PLURAL
ARTICLE_FORM_DE4No article; an item's plural name, and in
ARTICLE_FORM_MASK7French "de" in front
ARTICLE_FORM_INDEFINITE8Spanish: the indefinite article rather than the definite

Definition at line 126 of file window_decode.c.

anonymous enum

enum { ARTICLE_A, ARTICLE_AN }

The English articles (articles.c) a name with no article class takes.

EnumeratorValueDescription
ARTICLE_A1
ARTICLE_AN2before a capital vowel

Definition at line 144 of file window_decode.c.

Functions in detail

mnMessageAppendArticleName

Uint32 mnMessageAppendArticleName(Sint32 mode, Uint16 *name, Uint32 writePos, Uint16 *entries, Sint32 articleForm, Sint32 plural, Sint32 *suffix)

static inline Uint32 mnMessageAppendArticleName(Sint32 mode, Uint16 *name, Uint32 writePos, Uint16 *entries, Sint32 articleForm, Sint32 plural, Sint32 *suffix)

Copies a name into the decoded text at writePos and returns the position after it: with its article in front (ARTICLE_FORM_ARTICLE, or ARTICLE_FORM_BY_COUNT for one) and an s or es after it (ARTICLE_FORM_PLURAL, or ARTICLE_FORM_BY_COUNT for several). With mode set, a space and a line spacing of TEXT_DEFAULT_LINE_SPACING go before the name, and a line spacing of 8 and a space after it. suffix is left 1 when the name ends in s.

Copies a name into the decoded text at writePos and returns the position after it: ARTICLE_FORM_BARE and ARTICLE_FORM_DE take no article, the other forms the article of the name's class, its first letter a capital when suffix is 2 (a sentence's start); in French, ARTICLE_FORM_DE puts "de" (elided before a capital vowel) in front. mode sets the name apart as the English function does. suffix is left 1 when the name ends in s (in German also z or x).

Copies a name into the decoded text at writePos and returns the position after it. With mode set, a space and a line spacing of 10 go before the name, and a line spacing of 8 and a space after it. The other editions' function of this name, at the top of this file, also writes articles; Japanese has none, and its decoder inlines this copy.

References ArticleIndefinite, ArticleTable, Sint32 and TextDeArticles.

Referenced by mnMessageDecode().

Definition at lines 156, 246, 412 and 1036 of file window_decode.c.

mnMessageDecode

Sint32 mnMessageDecode(Sint32 msg, Sint32 clear)

Decodes message into the ring of decoded text (WIN_STATE.textBuf) after the text decoded last, and returns where it starts; message -1 returns the last decoded message's start again. Its argument codes take the message arguments (mnMessageArgumentPush), which clear set empties after. Halting speech (mnMessageSetDecodeFlags) puts a pause before each character and breaks the message off with "..." after its first word, or its first HALTING_SPEECH_LENGTH characters.

The Japanese mnMessageDecode: no articles or plurals, and a battle message (WINDOW_BATTLE_MESSAGE) sets its names off and doubles each space. Outside the field, the Mystery Man and Mystery Woman are named from MYSTERY_MAN_MESSAGE and the message after it rather than their unit names.

References fdAreaGetNameIndexStub(), gmUnitGet(), LocalizedWordCountedNouns, LocalizedWordItemGenders, LocalizedWordItemPossessives, MainRoutineStateWork, mnMessageAppendArticleName(), mnMessageArgumentClearAll(), mnMessageArgumentLookup(), mnMessageDecodeRaw(), mnMessageFind(), mnStringFormatNumber(), MsgClassName, Sint32, syHeapSlotRelease(), TextDecodeSymbolCode and TextDecodeSymbolCodeSize.

Referenced by mnBattleMessageOpen(), mnFieldMessageShowCentered(), mnMessageCopyExpanded(), mnMessageDecodeAndClearArguments(), mnMessageDecodeAppend(), mnMessageOpenDecoded(), mnMessageOpenWindow(), mnTextDrawMessage(), mnTextDrawMessageAsTiles(), mnTextDrawMessageToCanvas() and mnTextMeasureMessage().

Definition at lines 427 and 1070 of file window_decode.c.

Variables in detail

TextDecodeSymbolCode

extern const Uint8 TextDecodeSymbolCode[]

The symbol decoder RAM_CODE_LOAD copies to RAM to run, and its size, as this symbol's address.

Referenced by mnMessageDecode() and mnMessageDecodeRaw().

Definition at line 378 of file window_decode.c.

TextDecodeSymbolCodeSize

extern Uint8 TextDecodeSymbolCodeSize[]

Referenced by mnMessageDecode() and mnMessageDecodeRaw().

Definition at line 379 of file window_decode.c.

MsgClassName

extern Uint8 MsgClassName[], MsgItemName[], MsgAbilityName[], MsgDebugAreaName[]

Referenced by mnBattleDjinnMenuShowChangePreview(), mnBattleStatusScreenRun(), mnDjinnMenuDrawStatPreview(), mnDjinnMenuSelectDjinn(), mnFileListDrawSummary(), mnMessageDecode(), mnStatusScreenDrawPsynergyPage() and mnStatusScreenDrawTopRows().

Definition at line 381 of file window_decode.c.

MsgWaitingForOpponent

extern Uint8 MsgWaitingForOpponent[]

Referenced by mnBattleCollectPartyCommands().

Definition at line 1025 of file window_decode.c.