Skip to Content
The Alchemy Project

src/window/window_decode.c

The message decoder: articles, names and numbers written out. More…

Included by window.c.

Structures

NameDescription
structARTICLE_TABLEThe article written before a name of each article class.
structITEM_POSSESSIVE_TABLEThe possessive written before an item's name, chosen by the item's gender or by number.

Macros

NameDescription
#defineARTICLE_MAX_LETTERS 8The most letters of an article mnMessageAppendArticleName writes, and of a possessive or pronoun before an item's name.
#definePOSSESSIVE_MAX_LETTERS 16
#defineCHARACTER_CODE_MAX 255The highest character code outside Japanese: those fonts hold a byte's worth.
#defineKANA_FIRST_CODE 128The Japanese font's first kana (charmap_ja.tsv): its kana run to TEXT_LAST_FONT_CODE, and its kanji start at KANJI_FIRST_CODE (window.h).
#defineHALTING_SPEECH_MAX_CODES 10Halting speech, how a person the Halt Psynergy has stopped answers (fdTalkToActor), breaks off with an ellipsis at its first space, or after this many codes.
#defineBUTTON_ICON_FIRST_CODE 128MESSAGE_BUTTON_ICON's first character code.
#defineOPERAND_VALUE (stored) ((stored) + (Uint32)(Uint16)-1)The value of an operand the message stores one above it, taken one down as a halfword.
#defineUNIT_NAME_WIDEN (out, unitName, i)Copies the unit name at unitName into out, each byte widened to a character code, through the decoder's cursors nameBytes and nameOutput and its counter i.
#defineARTICLE_KINDS BY_LANGUAGE(8, 8, 8, 5, 8, 11)The article classes a name can take in each European language, and the bits of its class.
#defineARTICLE_KIND_MASK BY_LANGUAGE(7, 7, 7, 15, 7, 15)
#defineARTICLE_FORM_INDEFINITE 8In Spanish, the form's bit asking for the indefinite article rather than the definite one, above the form.
#defineARTICLE_FORM_MASK 7
#defineHALTING_SPEECH_PAUSE TEXT_PAUSE_SHORTWhat the decode flags of mnMessageSetDecodeFlags put between characters.
#defineVOICED_SPEECH_MARK TEXT_MARK_VOICEDWith voicedSpeech (English and Japanese), a voiced mark after a kana or the first kanji (KANA_FIRST_CODE to KANJI_FIRST_CODE), other than the kana marks and the Japanese full stop, comma and middle dot, unless the code after it is a kana mark.
#defineMYSTERY_PERSON_NAME_CODES 10The most codes the Japanese decoder takes of the name it gives the Mystery Man or the Mystery Woman in battle.

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 … }How a name argument is written ({argument_item_name:n} and the like, the catalogs showing the form one above): with or without its article, and singular or plural.
enumanonymous enum { LAST_LETTER_OTHER, LAST_LETTER_S, LAST_LETTER_SENTENCE_END }The state of the text just written, which an article or ending after it follows: a sentence's end capitalises the next article, and a name ending in s (in German, s or z) takes a different possessive or plural ending.
enumanonymous enum { ARTICLE_CLASS_NONE, ARTICLE_CLASS_A, ARTICLE_CLASS_AN }The English article classes mnMessageAppendArticleName chooses between (ArticleTable) when a name's class does not name one.

Functions

NameDescription
Uint32mnMessageAppendArticleName (Sint32 inBattleMsg, Uint16 *name, Uint32 writePos, Uint16 *entries, Sint32 articleForm, Sint32 plural, Sint32 *lastLetter)The German, Spanish, French and Italian form: the bare forms take no article, the others the article of the name's class, capitalised at the start of a sentence.
Sint32mnMessageDecode (Sint32 script, Sint32 clear)Decodes message script into the ring of decoded text (WIN_STATE.textBuf) and returns where it starts; script -1 returns the last message's start again.

Variables

NameDescription
extern Sint8LocalizedWordItemPronoun []
extern const struct ITEM_POSSESSIVE_TABLELocalizedWordItemPossessivesThe possessive ("your") for each item gender (LocalizedWordItemGenders).
extern const Sint8LocalizedWordItemGenders []
extern Uint8 *LocalizedWordCountedNouns []{singular, plural}: window.c reads [(kind & 7) * 2 + plural].

Description

The message decoder: articles, names and numbers written out. Part of window.c.

Macros in detail

ARTICLE_MAX_LETTERS

#define ARTICLE_MAX_LETTERS 8

The most letters of an article mnMessageAppendArticleName writes, and of a possessive or pronoun before an item's name.

Referenced by mnMessageAppendArticleName().

Definition at line 6 of file window_decode.c.

POSSESSIVE_MAX_LETTERS

#define POSSESSIVE_MAX_LETTERS 16

Referenced by mnMessageDecode().

Definition at line 7 of file window_decode.c.

CHARACTER_CODE_MAX

#define CHARACTER_CODE_MAX 255

The highest character code outside Japanese: those fonts hold a byte's worth.

Referenced by mnMessageDecode().

Definition at line 9 of file window_decode.c.

KANA_FIRST_CODE

#define KANA_FIRST_CODE 128

The Japanese font's first kana (charmap_ja.tsv): its kana run to TEXT_LAST_FONT_CODE, and its kanji start at KANJI_FIRST_CODE (window.h).

Referenced by mnMessageDecode().

Definition at line 12 of file window_decode.c.

HALTING_SPEECH_MAX_CODES

#define HALTING_SPEECH_MAX_CODES 10

Halting speech, how a person the Halt Psynergy has stopped answers (fdTalkToActor), breaks off with an ellipsis at its first space, or after this many codes.

Referenced by mnMessageDecode().

Definition at line 16 of file window_decode.c.

BUTTON_ICON_FIRST_CODE

#define BUTTON_ICON_FIRST_CODE 128

MESSAGE_BUTTON_ICON's first character code.

Referenced by mnMessageDecode().

Definition at line 18 of file window_decode.c.

OPERAND_VALUE

#define OPERAND_VALUE(stored) ((stored) + (Uint32)(Uint16)-1)

The value of an operand the message stores one above it, taken one down as a halfword.

Referenced by mnMessageDecode().

Definition at line 21 of file window_decode.c.

UNIT_NAME_WIDEN

#define UNIT_NAME_WIDEN(out, unitName, i)

Copies the unit name at unitName into out, each byte widened to a character code, through the decoder's cursors nameBytes and nameOutput and its counter i. It is several statements, so it is used only as a whole statement of a case.

Referenced by mnMessageDecode().

Definition at line 27 of file window_decode.c.

ARTICLE_KINDS

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

The article classes a name can take in each European language, and the bits of its class.

Definition at line 42 of file window_decode.c.

ARTICLE_KIND_MASK

#define ARTICLE_KIND_MASK BY_LANGUAGE(7, 7, 7, 15, 7, 15)

Referenced by mnMessageAppendArticleName().

Definition at line 43 of file window_decode.c.

ARTICLE_FORM_INDEFINITE

#define ARTICLE_FORM_INDEFINITE 8

In Spanish, the form's bit asking for the indefinite article rather than the definite one, above the form.

Referenced by mnMessageAppendArticleName().

Definition at line 141 of file window_decode.c.

ARTICLE_FORM_MASK

#define ARTICLE_FORM_MASK 7

Referenced by mnMessageAppendArticleName() and mnMessageDecode().

Definition at line 142 of file window_decode.c.

HALTING_SPEECH_PAUSE

#define HALTING_SPEECH_PAUSE TEXT_PAUSE_SHORT

What the decode flags of mnMessageSetDecodeFlags put between characters. Halting speech pauses before each one.

Referenced by mnMessageDecode().

Definition at line 366 of file window_decode.c.

VOICED_SPEECH_MARK

#define VOICED_SPEECH_MARK TEXT_MARK_VOICED

With voicedSpeech (English and Japanese), a voiced mark after a kana or the first kanji (KANA_FIRST_CODE to KANJI_FIRST_CODE), other than the kana marks and the Japanese full stop, comma and middle dot, unless the code after it is a kana mark. No message is decoded with it.

Referenced by mnMessageDecode().

Definition at line 371 of file window_decode.c.

MYSTERY_PERSON_NAME_CODES

#define MYSTERY_PERSON_NAME_CODES 10

The most codes the Japanese decoder takes of the name it gives the Mystery Man or the Mystery Woman in battle.

Referenced by mnMessageDecode().

Definition at line 952 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_STYLE: the style of sprite text, 1 outlined (mnTextDrawGlyphPair), 2 to 5 a motion (mnGlyphDraw).
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_EM_DASH24A dash: TEXT_EM_DASH_LEAD and a hyphen, and outside English a space after; the Japanese decoder keeps the code as it is.
MESSAGE_PLURAL_SUFFIX25English: the plural suffix; German, Spanish, French and Italian: the item's possessive
MESSAGE_BUTTON_ICON26A button drawn as two characters, codes 128 + 2 * n and the next for operand value n; the Japanese decoder keeps the code as it is.
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. The Japanese decoder keeps the code as it is.
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.

Definition at line 55 of file window_decode.c.

ARTICLE_FORM

enum ARTICLE_FORM

How a name argument is written ({argument_item_name:n} and the like, the catalogs showing the form one above): with or without its article, and singular or plural.

EnumeratorValueDescription
ARTICLE_FORM_BARE0The name alone.
ARTICLE_FORM_ARTICLE1The name after its article ("a Herb").
ARTICLE_FORM_PLURAL2English: the name with its plural ending ("Herbs"); the other European languages: the plural name after its article.
ARTICLE_FORM_BY_NUMBER3ARTICLE_FORM_ARTICLE or ARTICLE_FORM_PLURAL, by the number argument written before it.
ARTICLE_FORM_BARE_PLURAL4Outside English: the plural name alone.

Definition at line 126 of file window_decode.c.

anonymous enum

enum { LAST_LETTER_OTHER, LAST_LETTER_S, LAST_LETTER_SENTENCE_END }

The state of the text just written, which an article or ending after it follows: a sentence's end capitalises the next article, and a name ending in s (in German, s or z) takes a different possessive or plural ending.

EnumeratorValueDescription
LAST_LETTER_OTHER0
LAST_LETTER_S1
LAST_LETTER_SENTENCE_END2

Definition at line 148 of file window_decode.c.

anonymous enum

enum { ARTICLE_CLASS_NONE, ARTICLE_CLASS_A, ARTICLE_CLASS_AN }

The English article classes mnMessageAppendArticleName chooses between (ArticleTable) when a name's class does not name one.

EnumeratorValueDescription
ARTICLE_CLASS_NONE0
ARTICLE_CLASS_A1
ARTICLE_CLASS_AN2

Definition at line 270 of file window_decode.c.

Functions in detail

mnMessageAppendArticleName

Uint32 mnMessageAppendArticleName(Sint32 inBattleMsg, Uint16 *name, Uint32 writePos, Uint16 *entries, Sint32 articleForm, Sint32 plural, Sint32 *lastLetter)

extern __inline__ Uint32 mnMessageAppendArticleName(Sint32 inBattleMsg, Uint16 *name, Uint32 writePos, Uint16 *entries, Sint32 articleForm, Sint32 plural, Sint32 *lastLetter)

The German, Spanish, French and Italian form: the bare forms take no article, the others the article of the name's class, capitalised at the start of a sentence.

The English form: the singular takes "a" or "an" (by the name's first letter, unless its class names an article), and the plural adds "s", or "es" after an s.

The Japanese form: Japanese has no articles, so the name is copied as it is.

References ArticleIndefinite, ArticleTable and Sint32.

Referenced by mnMessageDecode().

Definition at lines 165, 280 and 955 of file window_decode.c.

mnMessageDecode

Sint32 mnMessageDecode(Sint32 script, Sint32 clear)

Decodes message script into the ring of decoded text (WIN_STATE.textBuf) and returns where it starts; script -1 returns the last message's start again.

The Japanese mnMessageDecode: the European decoder's loop without its articles, plurals, possessives, dashes, button icons and opening quotes. What only this one does: halting speech breaks off with ・・・。 rather than "...", a battle message doubles each space and sets off each name with spaces and line spacing codes (mnMessageAppendArticleName above), and in battle the Mystery Man and Mystery Woman take their names from MsgMysteryPersonName.

References fdAreaGetNameIndexStub(), gmUnitGetStub(), LocalizedWordCountedNouns, LocalizedWordItemGenders, LocalizedWordItemPossessives, MainRoutineStateWork, mnMessageAppendArticleName(), mnMessageArgumentClearAll(), mnMessageArgumentLookup(), mnMessageDecodeRaw(), mnMessageFind(), mnStringFormatNumber(), Sint32, state, syHeapSlotRelease(), TextDecodeSymbol and TextDecodeSymbolCodeSize.

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

Definition at lines 396 and 991 of file window_decode.c.