src/window/window_messages.c
Messages copied out as strings, the message arguments, closing windows, a message's flash, the story crawl's text, the symbol decoder and the portrait windows. More…
Included by window.c.
Macros
| Name | Description | |
|---|---|---|
#define | MESSAGE_CAPACITY_UNLIMITED ((Uint32)-1 >> 1) | A capacity no message reaches: the largest Sint32. |
#define | SYMBOL_TREE_MASK 0xff | The previous code's low byte, which picks a symbol's tree in its bank. |
#define | BIT_STREAM_STOP (1 << 7) | A byte of the bit stream as it is read from: the first bit taken, the seven left, and a stop bit above them that reads as the last 1 with nothing left, when the next byte is loaded. |
#define | DECODE_EUROPEAN | |
#define | FLASH_PICTURE_BYTES (8 * TILE_SIZE_4BPP) | The flash border is a strip of pictures of eight tiles each, the one shown loaded over the window tiles 8 to 15. |
#define | FLASH_PICTURE_VRAM (BG_CHAR_BLOCK(0) + 8 * TILE_SIZE_4BPP) | |
#define | CRAWL_CANVAS_WIDTH 192 | The story crawl's canvas, one byte a pixel: a line of 24 tiles of the credits' tile ring. |
#define | PLOT_GLYPH_ROWS JAPANESE_OR(12, 14) | The rows of a glyph drawn: all twelve of the Japanese font's, and fourteen of the European fonts' fifteen. |
#define | PORTRAIT_FIRST_SPRITE_SPEAKER 16 | A speaker below this is a character, found in PortraitCharacterMap; one from it on is a sprite, found in PortraitSpriteMap. |
Functions
| Name | Description | |
|---|---|---|
void | mnMessageDecodeRawUnbounded (Sint32 msg, Uint16 *text) | Decodes message into text (a Uint16 string) with no length limit: text must have room for the whole message and its terminator. |
Sint32 | mnMessageCopyExpanded (Sint32 msg, Uint16 *dest, Uint32 capacity) | Decodes message into destination as a zero-terminated string of at most capacity entries, and returns its length. capacity counts halfwords including the terminator and must be at least 1. |
void | mnMessageDecodeRaw (Sint32 msg, Uint16 *text, Sint32 capacity) | Decodes message into text as a zero-terminated string of 16-bit codes, with at most capacity entries, keeping style codes with their operands. |
Sint32 * | mnMemoryClearWordIfSet (Sint32 *p) | Unused: clears *p if nonzero and returns p. |
void | mnWindowCloseAll (void) | Closes every window: first the messages' windows, waiting until they have closed, then the windows opened directly, which it does not wait for. |
void | mnWindowShowFlashFrame (WINDOW **window, Sint32 offset) | Loads the flash border's picture that starts offset bytes into its strip (ResourceIdWindowBorderFlash) and draws the window's border in it. |
void | mnWindowStepSwellEffect (MESSAGE *msg) | Steps a message window's swell (WINDOW_ANIMATION_SWELL) by a tick. |
void | mnMessageArgumentClearAll (void) | Empties the table of message arguments. |
void | mnMessageArgumentPush (Uint32 value, Uint32 kind) | Adds a message argument of kind (MESSAGE_ARGUMENT_) with value to the first free place of the argument table; when all eight are in use it is dropped. |
Uint32 | mnMessageArgumentLookup (Uint32 kind, Uint32 clear) | Returns the value of the first message argument of kind (MESSAGE_ARGUMENT_), or 0 when there is none. |
Bool | mnTextCheckPauseSkipped (MESSAGE *msg) | Ends a message's pause early: when the message waits on a sound that has finished, or while A, B, L or R is held. |
Bool | mnTextCheckTextDismissed (MESSAGE *msg) | As mnTextCheckPauseSkipped, but on a newly pressed button (the latched presses while WIN_STATE.mindRead is set). |
void | mnMessageCloseFinishedWindows (void) | Closes each message's window whose text has ended, then waits ten ticks. |
void | mnFieldMessageShowCentered (Sint32 msg, Sint32 style, Sint32 yOffset) | Shows message msg centred across the screen and in its top 15 rows (yOffset tiles lower), waits until it is typed out, then closes it: in a window, or with CENTERED_MESSAGE_BARE as bare text in a window of no size. |
Sint32 | mnMessageDecodeAndClearArguments (Sint32 msg) | Decodes message and empties the argument table; returns where its decoded text starts. |
void | mnMessageDecodeAppend (Sint32 msg) | Decodes message after the text decoded last, over its terminator. |
void | mnTextPlotGlyphRows (Uint16 *rows, Uint8 *dest, Sint32 color) | Plots a glyph's rows of bits onto the story crawl's canvas at dest, one byte a pixel in color, leftmost pixel from the high bit; clear bits are left. |
Sint32 | mnTextDrawGlyphToCanvas (Uint8 *canvas, Uint32 ch, Sint32 x, Sint32 row) | Draws a character on the canvas at (x, row) with its shadow and returns its width: a font glyph, or a kanji from KANJI_FIRST_CODE on, with the mark its code carries above TEXT_MARK_SHIFT drawn over it one pixel wider. |
Sint32 | mnTextDrawMessageToCanvas (Sint32 msg, Uint8 *canvas) | Draws message centred in a 192-pixel canvas of one byte a pixel, as the story crawl draws its lines. |
void | mnMessageFind (TEXT_READER *reader, Sint32 msg) | Points reader at the start of message (its compressed bits and first context), running the ARM lookup function from a RAM copy, which it frees before returning. |
Sint32 | mnTextDecodeSymbolInC (TEXT_READER *reader) | Unused: the symbol decoder in C, as the copy run from RAM (TextDecodeSymbolCode) decodes. |
void | mnPortraitClearSlots (void) | Marks both portrait slots free (PORTRAIT_SLOT_EMPTY), as the window system's field setup does. |
Sint32 | mnPortraitGetForSpeaker (Uint32 speaker) | Returns the portrait a speaker's messages show, or -1 when it has none: a character's (speakers below PORTRAIT_FIRST_SPRITE_SPEAKER) from PortraitCharacterMap, or a sprite's from PortraitSpriteMap, numbered on from PORTRAIT_FIRST_SPRITE_PORTRAIT. |
WINDOW * | mnPortraitOpenWindow (Sint32 speaker, Sint32 portraitOption, Sint32 x, Sint32 y) | Opens a portrait window at tile (x, y) showing the speaker's portrait. portraitOption is passed on through mnPortraitCreate to mnIconLoadWithPalette, which ignores it. |
void | mnPortraitCloseWindow (Sint32 speaker) | Closes at once the portrait window showing the speaker's portrait, if one is open: the window whose first sprite is that portrait slot's. |
Variables
| Name | Description | |
|---|---|---|
extern const Uint8 | TextDecodeSymbolCode [] | The message decoder's ARM code, run from a RAM copy, and its size. |
extern Uint8 | TextDecodeSymbolCodeSize [] | |
extern const void *const | TextMessageContexts [][2] | Each decoding context's Huffman tree and its symbols, two pointers a row: a message's previous symbol picks the row. |
Description
Messages copied out as strings, the message arguments, closing windows, a
message's flash, the story crawl's text, the symbol decoder and the portrait
windows. Part of window.c.
Macros in detail
MESSAGE_CAPACITY_UNLIMITED
#define MESSAGE_CAPACITY_UNLIMITED ((Uint32)-1 >> 1)
A capacity no message reaches: the largest Sint32.
Referenced by mnMessageDecodeRawUnbounded().
Definition at line 13 of file window_messages.c.
SYMBOL_TREE_MASK
#define SYMBOL_TREE_MASK 0xff
The previous code's low byte, which picks a symbol's tree in its bank.
Referenced by mnTextDecodeSymbolInC().
Definition at line 16 of file window_messages.c.
BIT_STREAM_STOP
#define BIT_STREAM_STOP (1 << 7)
A byte of the bit stream as it is read from: the first bit taken, the seven left, and a stop bit above them that reads as the last 1 with nothing left, when the next byte is loaded.
Referenced by mnTextDecodeSymbolInC().
Definition at line 20 of file window_messages.c.
DECODE_EUROPEAN
#define DECODE_EUROPEAN
Definition at line 53 of file window_messages.c.
FLASH_PICTURE_BYTES
#define FLASH_PICTURE_BYTES (8 * TILE_SIZE_4BPP)
The flash border is a strip of pictures of eight tiles each, the one shown loaded over the window tiles 8 to 15.
Referenced by mnWindowShowFlashFrame() and mnWindowStepSwellEffect().
Definition at line 203 of file window_messages.c.
FLASH_PICTURE_VRAM
#define FLASH_PICTURE_VRAM (BG_CHAR_BLOCK(0) + 8 * TILE_SIZE_4BPP)
Referenced by mnWindowShowFlashFrame() and mnWindowStepSwellEffect().
Definition at line 204 of file window_messages.c.
CRAWL_CANVAS_WIDTH
#define CRAWL_CANVAS_WIDTH 192
The story crawl's canvas, one byte a pixel: a line of 24 tiles of the credits' tile ring.
Referenced by mnTextDrawGlyphToCanvas(), mnTextDrawMessageToCanvas() and mnTextPlotGlyphRows().
Definition at line 471 of file window_messages.c.
PLOT_GLYPH_ROWS
#define PLOT_GLYPH_ROWS JAPANESE_OR(12, 14)
The rows of a glyph drawn: all twelve of the Japanese font's, and fourteen of the European fonts' fifteen.
Referenced by mnTextPlotGlyphRows().
Definition at line 475 of file window_messages.c.
PORTRAIT_FIRST_SPRITE_SPEAKER
#define PORTRAIT_FIRST_SPRITE_SPEAKER 16
A speaker below this is a character, found in PortraitCharacterMap; one from
it on is a sprite, found in PortraitSpriteMap.
Referenced by mnPortraitGetForSpeaker().
Definition at line 794 of file window_messages.c.
Functions in detail
mnMessageDecodeRawUnbounded
void mnMessageDecodeRawUnbounded(Sint32 msg, Uint16 *text)
Decodes message into text (a Uint16 string) with no length limit: text must have room for the whole message and its terminator.
References mnMessageDecodeRaw() and Sint32.
Referenced by fdMessageDecodeRawUnbounded().
Definition at line 24 of file window_messages.c.
mnMessageCopyExpanded
Sint32 mnMessageCopyExpanded(Sint32 msg, Uint16 *dest, Uint32 capacity)
Decodes message into destination as a zero-terminated string of at most capacity entries, and returns its length. capacity counts halfwords including the terminator and must be at least 1.
References mnMessageDecode() and Sint32.
Referenced by mnBattleDjinnMenuRun() and mnBattleStatusScreenRun().
Definition at line 32 of file window_messages.c.
mnMessageDecodeRaw
void mnMessageDecodeRaw(Sint32 msg, Uint16 *text, Sint32 capacity)
Decodes message into text as a zero-terminated string of 16-bit codes, with at most capacity entries, keeping style codes with their operands.
References mnMessageFind(), Sint32, syHeapSlotRelease(), TextDecodeSymbolCode and TextDecodeSymbolCodeSize.
Referenced by mnMessageDecode() and mnMessageDecodeRawUnbounded().
Definition at line 58 of file window_messages.c.
mnMemoryClearWordIfSet
Sint32 *mnMemoryClearWordIfSet(Sint32 *p)
Unused: clears *p if nonzero and returns p.
References Sint32.
Definition at line 126 of file window_messages.c.
mnWindowCloseAll
void mnWindowCloseAll(void)
Closes every window: first the messages' windows, waiting until they have closed, then the windows opened directly, which it does not wait for.
References mnWindowClose(), Sint32 and sySynch().
Definition at line 137 of file window_messages.c.
mnWindowShowFlashFrame
void mnWindowShowFlashFrame(WINDOW **window, Sint32 offset)
Loads the flash border's picture that starts offset bytes into its strip
(ResourceIdWindowBorderFlash) and draws the window's border in it.
References mnWindowDrawFlashBorder(), Sint32, syDMAXCopy() and syResourceGetTableEntry().
Referenced by mnWindowStepSwellEffect().
Definition at line 208 of file window_messages.c.
mnWindowStepSwellEffect
void mnWindowStepSwellEffect(MESSAGE *msg)
Steps a message window's swell (WINDOW_ANIMATION_SWELL) by a tick. As the
countdown runs down from 10 the border flashes through the strip's fourth,
third and second pictures and back, turns plain again two ticks before the
end, and the first picture is put back in tiles 8 to 15.
References mnWindowDrawBorder(), mnWindowShowFlashFrame(), syDMAXCopy() and syResourceGetTableEntry().
Referenced by mnMessageUpdateAll().
Definition at line 229 of file window_messages.c.
mnMessageArgumentClearAll
void mnMessageArgumentClearAll(void)
Empties the table of message arguments.
References Sint32.
Referenced by mnBattleDjinnMenuRun(), mnBattleStatusScreenRun(), mnMessageDecode() and scLinkLobbyReportWinTallies().
Definition at line 263 of file window_messages.c.
mnMessageArgumentPush
void mnMessageArgumentPush(Uint32 value, Uint32 kind)
Adds a message argument of kind (MESSAGE_ARGUMENT_) with value to the first
free place of the argument table; when all eight are in use it is dropped.
Referenced by dbIncreaseItemAndLevelShowCharacterName(), dbPsynergyTestBrowseMessageRange(), dbShopTestBrowseMessageRange(), dbShopTestTalkToSunshinesWife(), mnBattleDjinnMenuRun(), mnBattleStatusScreenRun(), mnDjinnShowJoinedMessage(), mnPartyShowJoinedMessage(), mnPartyShowPairJoinedMessage(), mnSummonShowLearnedMessage(), scAquaRockInsideCheckColumn(), scContigoInitLuckyDice(), scContigoOfferLuckyDice(), scContigoOfferLuckyWheels(), scContigoReportCoinChange(), scDailaRoomsGiveItem(), scDailaRoomsTakeSeaGodsTear(), scInit(), scLemuriaSpringRunSpringGame(), scLinkLobbyReportMonsterRecord(), scLinkLobbyReportWinTallies(), scMadraMeetKarst(), scNaribweRoomsReadFortune(), scShamanVillageTalkToInnkeeper(), scTrialRoadPutItemInChest(), scWorldMapMeetEcho(), scWorldMapSetUpFlyingShip() and scYallamRoomsTalkToSunshinesWife().
Definition at line 279 of file window_messages.c.
mnMessageArgumentLookup
Uint32 mnMessageArgumentLookup(Uint32 kind, Uint32 clear)
Returns the value of the first message argument of kind (MESSAGE_ARGUMENT_),
or 0 when there is none.
Referenced by mnMessageDecode().
Definition at line 299 of file window_messages.c.
mnTextCheckPauseSkipped
Bool mnTextCheckPauseSkipped(MESSAGE *msg)
Ends a message's pause early: when the message waits on a sound that has finished, or while A, B, L or R is held.
References PerWork and sySoundGetBGMRestoreDelayStub().
Referenced by mnMessageType().
Definition at line 323 of file window_messages.c.
mnTextCheckTextDismissed
Bool mnTextCheckTextDismissed(MESSAGE *msg)
As mnTextCheckPauseSkipped, but on a newly pressed button (the latched
presses while WIN_STATE.mindRead is set). While B is held the text also goes
on by itself once the wait's countdown runs down
(MessageSpeedHeldPageDelays); while it is up the countdown stays at 2.
References PerWork and sySoundGetBGMRestoreDelayStub().
Referenced by mnMessageType().
Definition at line 346 of file window_messages.c.
mnMessageCloseFinishedWindows
void mnMessageCloseFinishedWindows(void)
Closes each message's window whose text has ended, then waits ten ticks.
References mnWindowClose(), Sint32 and sySynch().
Referenced by dbPsynergyTestBrowseMessageRange(), dbPsynergyTestShowMessageAndWait(), dbShopTestBrowseMessageRange(), mnSaveEraseSelectedFile(), mnSaveToChosenFile(), mnSaveToFile(), scAncientLemuriaMeetTheLemurians(), scDailaRoomsGiveItem(), scInit(), scLemuriaEntranceShowLineWithPortrait(), scLemuriaSpringRunSpringGame(), scShamanVillageCaveLoseToGladiators() and scWorldMapSetUpFlyingShip().
Definition at line 377 of file window_messages.c.
mnFieldMessageShowCentered
void mnFieldMessageShowCentered(Sint32 msg, Sint32 style, Sint32 yOffset)
Shows message msg centred across the screen and in its top 15 rows
(yOffset tiles lower), waits until it is typed out, then closes it: in a
window, or with CENTERED_MESSAGE_BARE as bare text in a window of no size.
References mnMessageAllTyped(), mnMessageDecode(), mnMessageStart(), mnTextGetMessageSize(), mnWindowClose(), mnWindowCreate(), mnWindowIsClosed(), Sint32 and sySynch().
Referenced by scAnemosInnerSanctumApproachCharonSlate(), scAnemosInnerSanctumDullahanShadowChallenges(), scGabombaStatueChamberGabombaNamesWitchDoctor(), scGabombaStatueChamberStatueSpeaks(), scGarohRoomsWakeAtInn(), scInit(), scJupiterLighthouseHearTheVoice(), scMarsLighthouseStarRoomTakeMarsStar(), scScriptMessageShowCentered() and scTreasureIsleMeetStarMagician().
Definition at line 403 of file window_messages.c.
mnMessageDecodeAndClearArguments
Sint32 mnMessageDecodeAndClearArguments(Sint32 msg)
Decodes message and empties the argument table; returns where its decoded
text starts. The Djinn and party join messages (screens_joined.c) use it.
References mnMessageDecode() and Sint32.
Referenced by mnDjinnShowJoinedMessage(), mnPartyShowJoinedMessage(), mnPartyShowPairJoinedMessage() and mnSummonShowLearnedMessage().
Definition at line 453 of file window_messages.c.
mnMessageDecodeAppend
void mnMessageDecodeAppend(Sint32 msg)
Decodes message after the text decoded last, over its terminator.
References mnMessageDecode() and Sint32.
Referenced by mnSummonShowLearnedMessage().
Definition at line 459 of file window_messages.c.
mnTextPlotGlyphRows
void mnTextPlotGlyphRows(Uint16 *rows, Uint8 *dest, Sint32 color)
Plots a glyph's rows of bits onto the story crawl's canvas at dest, one byte a pixel in color, leftmost pixel from the high bit; clear bits are left.
References Sint32.
Referenced by mnTextDrawGlyphToCanvas().
Definition at line 479 of file window_messages.c.
mnTextDrawGlyphToCanvas
Sint32 mnTextDrawGlyphToCanvas(Uint8 *canvas, Uint32 ch, Sint32 x, Sint32 row)
Sint32 mnTextDrawGlyphToCanvas(Uint8 *canvas, Sint32 ch, Sint32 x, Sint32 row)
Draws a character on the canvas at (x, row) with its shadow and returns its
width: a font glyph, or a kanji from KANJI_FIRST_CODE on, with the mark its
code carries above TEXT_MARK_SHIFT drawn over it one pixel wider.
Draws a character on the canvas at (x, row) with its shadow and returns its width.
References FontGlyphs, FontKanjiGlyphs, FontMarkGlyphCodes, mnTextPlotGlyphRows() and Sint32.
Referenced by mnTextDrawMessageToCanvas().
Definition at lines 506 and 551 of file window_messages.c.
mnTextDrawMessageToCanvas
Sint32 mnTextDrawMessageToCanvas(Sint32 msg, Uint8 *canvas)
Draws message centred in a 192-pixel canvas of one byte a pixel, as the story crawl draws its lines. A line of dashes draws nothing and returns how many dashes past the first it has (the crawl waits on it); any other line returns 0.
References mnMessageDecode(), mnTextDrawGlyphToCanvas(), mnTextMeasureDecoded(), mnTextResetStyle() and Sint32.
Definition at line 574 of file window_messages.c.
mnMessageFind
void mnMessageFind(TEXT_READER *reader, Sint32 msg)
Points reader at the start of message (its compressed bits and first context), running the ARM lookup function from a RAM copy, which it frees before returning.
References Sint32, syHeapRelease(), TextLookupSymbolCode and TextLookupSymbolCodeSize.
Referenced by mnMessageDecode() and mnMessageDecodeRaw().
Definition at line 665 of file window_messages.c.
mnTextDecodeSymbolInC
Sint32 mnTextDecodeSymbolInC(TEXT_READER *reader)
Unused: the symbol decoder in C, as the copy run from RAM
(TextDecodeSymbolCode) decodes. Messages are Huffman coded with one tree per
previous symbol: the previous code picks the tree, the message's bits walk it
to a leaf, and the leaf's 12-bit symbol is returned and becomes the next
context. reader->bytes keeps the byte the bits are read from between calls.
References Sint32 and TextMessageContexts.
Definition at line 679 of file window_messages.c.
mnPortraitClearSlots
void mnPortraitClearSlots(void)
Marks both portrait slots free (PORTRAIT_SLOT_EMPTY), as the window system's
field setup does.
References Sint32.
Referenced by mnWindowSystemInitField().
Definition at line 781 of file window_messages.c.
mnPortraitGetForSpeaker
Sint32 mnPortraitGetForSpeaker(Uint32 speaker)
Returns the portrait a speaker's messages show, or -1 when it has none: a
character's (speakers below PORTRAIT_FIRST_SPRITE_SPEAKER) from
PortraitCharacterMap, or a sprite's from PortraitSpriteMap, numbered on from
PORTRAIT_FIRST_SPRITE_PORTRAIT.
References PortraitCharacterMap, PortraitSpriteMap and Sint32.
Referenced by mnDjinnShowJoinedMessage(), mnPartyShowJoinedMessage(), mnPartyShowPairJoinedMessage(), mnPortraitCloseWindow(), mnPortraitCreate(), mnPortraitLoad(), mnPortraitOpenWindow() and mnPortraitReload().
Definition at line 800 of file window_messages.c.
mnPortraitOpenWindow
WINDOW * mnPortraitOpenWindow(Sint32 speaker, Sint32 portraitOption, Sint32 x, Sint32 y)
Opens a portrait window at tile (x, y) showing the speaker's portrait.
portraitOption is passed on through mnPortraitCreate to
mnIconLoadWithPalette, which ignores it.
References mnPortraitCreate(), mnPortraitGetForSpeaker(), mnWindowCreate() and Sint32.
Referenced by dbPsynergyTestBrowseMessageRange(), dbShopTestBrowseMessageRange(), mnDebugBrowserPortraits(), mnNameEntryEditMemberName(), scChampaShowTwoMessages(), scEpilogueShowLineAt() and scLemuriaEntranceShowLineWithPortrait().
Definition at line 859 of file window_messages.c.
mnPortraitCloseWindow
void mnPortraitCloseWindow(Sint32 speaker)
Closes at once the portrait window showing the speaker's portrait, if one is open: the window whose first sprite is that portrait slot's.
References mnPortraitGetForSpeaker(), mnWindowClose() and Sint32.
Referenced by mnNameEntryEditMemberName().
Definition at line 901 of file window_messages.c.
Variables in detail
TextMessageContexts
extern const void *const TextMessageContexts[][2]
Each decoding context's Huffman tree and its symbols, two pointers a row: a message's previous symbol picks the row.
Referenced by mnTextDecodeSymbolInC().
Definition at line 10 of file window_messages.c.