Skip to Content
The Alchemy Project

src/window/window_messages.c

Message strings and arguments, symbol decoding and portrait windows. More…

Included by window.c.

Macros

NameDescription
#defineMESSAGE_CAPACITY_UNLIMITED 0x7fffffffA capacity no message reaches: the largest Sint32.
#defineSYMBOL_TREE_MASK 0xffThe previous code's low byte, which picks a symbol's tree in its bank.
#defineBIT_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.
#defineDECODE_EUROPEAN

Functions

NameDescription
voidmnMessageDecodeRawUnbounded (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.
Sint32mnMessageCopyExpanded (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.
voidmnMessageDecodeRaw (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: zeroes the word at p unless it is already 0, and returns p.
voidmnWindowCloseAll (Sint32 unused)Closes every window: first the messages' windows, waiting until they have closed, then the windows opened directly, which it does not wait for.
voidmnWindowStepSwellEffect (MESSAGE *msg)Steps a message's window animation (WINDOW_ANIMATION_SWELL): the tick is drawn a tile bigger on every side until the countdown ends, then back to normal.
voidmnMessageArgumentClearAll (void)Empties the table of message arguments.
voidmnMessageArgumentPush (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.
Uint32mnMessageArgumentLookup (Uint32 kind, Uint32 clear)Returns the value of the first message argument of kind (MESSAGE_ARGUMENT_), or 0 when there is none.
BoolmnTextCheckPauseSkipped (MESSAGE *msg)Ends a message's pause early, returning 1: when the message waits on a sound that has finished, or while A, B, L or R is held.
BoolmnTextCheckTextDismissed (MESSAGE *msg)As mnTextCheckPauseSkipped, but on a newly pressed button: the latched presses while WIN_STATE.mindRead is set.
voidmnMessageCloseFinishedWindows (void)Closes each message's window whose text has ended, then waits ten ticks.
voidmnFieldMessageShowCentered (Sint32 msg, Sint32 mode, Sint32 yOffset)Shows a message centred across the screen and in its top 15 rows (yOffset tiles lower), waits until it is typed out and closes it, in the window mode (CENTERED_MESSAGE_MODE) asks for.
Sint32mnMessageDecodeAndClearArguments (Sint32 msg)Decodes message and empties the argument table; returns where its decoded text starts.
voidmnMessageFind (MESSAGE_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.
Sint32mnTextDecodeSymbolInC (MESSAGE_READER *reader)Unused: decodes the next symbol of a message, as TextDecodeSymbol, the copy the game runs from RAM, does.
voidmnPortraitClearSlots (void)Marks both portrait slots free (PORTRAIT_SLOT_EMPTY).
Sint32mnPortraitGetForSpeaker (Uint32 speaker)Returns the portrait of a character or another speaker's sprite, or -1 when it has none: speakers up to Garet's child sprite take theirs from PortraitCharacterMap, the others from PortraitSpriteMap, numbered from PORTRAIT_SPRITE_MAP_FIRST (mnIconLoadWithPalette takes it as the row PORTRAIT_JUPITER_DJINNI).
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.
voidmnPortraitCloseWindow (Uint32 speaker)Closes the window showing a speaker's portrait, if one is open, at once: the portrait slot showing it names its window sprite, the first sprite of its window.

Description

Message strings and arguments, symbol decoding and portrait windows. Part of window.c.

Macros in detail

MESSAGE_CAPACITY_UNLIMITED

#define MESSAGE_CAPACITY_UNLIMITED 0x7fffffff

A capacity no message reaches: the largest Sint32.

Referenced by mnMessageDecodeRawUnbounded().

Definition at line 5 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 8 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 12 of file window_messages.c.

DECODE_EUROPEAN

#define DECODE_EUROPEAN

Definition at line 45 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 mnFieldMessageDecodeRawUnbounded().

Definition at line 16 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(), Sint32 and state.

Referenced by mnBattleDjinnMenuRun() and mnBattleStatusScreenRun().

Definition at line 24 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 HeapSlots, mnMessageFind(), Sint32, syHeapSlotRelease(), TextDecodeSymbol and TextDecodeSymbolCodeSize.

Referenced by mnMessageDecode() and mnMessageDecodeRawUnbounded().

Definition at line 50 of file window_messages.c.

mnMemoryClearWordIfSet

Sint32 *mnMemoryClearWordIfSet(Sint32 *p)

Unused: zeroes the word at p unless it is already 0, and returns p.

References Sint32.

Definition at line 124 of file window_messages.c.

mnWindowCloseAll

void mnWindowCloseAll(Sint32 unused)

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, state and sySynch().

Definition at line 137 of file window_messages.c.

mnWindowStepSwellEffect

void mnWindowStepSwellEffect(MESSAGE *msg)

Steps a message's window animation (WINDOW_ANIMATION_SWELL): the tick is drawn a tile bigger on every side until the countdown ends, then back to normal.

References mnWindowDrawBorder(), mnWindowEraseBorderRect(), Sint32 and width.

Referenced by mnMessageUpdateAll().

Definition at line 211 of file window_messages.c.

mnMessageArgumentClearAll

void mnMessageArgumentClearAll(void)

Empties the table of message arguments.

References Sint32 and state.

Referenced by mnBattleDjinnMenuRun(), mnMessageDecode() and scBattleArenaTellLinkedWins().

Definition at line 234 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.

References state.

Referenced by dbMenuTestBrowseMessageRange(), mnBattleDjinnMenuRun(), mnBattleStatusScreenRun(), mnDjinnShowJoinedMessage(), mnPartyShowJoinedMessage(), mnPartyShowPairJoinedMessage(), scBabiPalaceMeetBabiAfterColosso(), scBattleArenaReportMonsterRecord(), scBattleArenaTellLinkedWins(), scColossoGreetAtStage(), scColossoOfferCheeringSpot(), scColossoRepeatStageNumber(), scColossoTakePrize(), scInit(), scKalayTolbiDocksTalkToWomanSellingTickets(), scMercuryLighthouseFillHermesWaterBottle(), scSolSanctumElementalStarRoomBagJupiterStar(), scSolSanctumElementalStarRoomBagMercuryStar(), scSolSanctumElementalStarRoomBagVenusStar(), scSolSanctumElementalStarRoomTakeMarsStar(), scStuccoRoomsCOfferLuckyDice(), scStuccoRoomsCOfferLuckyWheels(), scTolbiSpringRunSpringGame() and scWorldMapMeetFlint().

Definition at line 250 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.

References state.

Referenced by mnMessageDecode().

Definition at line 270 of file window_messages.c.

mnTextCheckPauseSkipped

Bool mnTextCheckPauseSkipped(MESSAGE *msg)

Ends a message's pause early, returning 1: when the message waits on a sound that has finished, or while A, B, L or R is held.

References PerData, state and sySoundGetBGMRestoreDelayStub().

Referenced by mnMessageType().

Definition at line 294 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.

References PerPush, PerPushLatch, Sint32, state and sySoundGetBGMRestoreDelayStub().

Referenced by mnMessageType().

Definition at line 313 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 dbMenuTestBrowseMessageRange(), dbMenuTestShowMessageAndWait(), mnSaveConfirmAndWriteLinkTallies(), mnSaveEraseSelectedFile(), mnSaveToChosenFile(), scInit(), scTolbiSpringRunSpringGame() and scValePlazaUsePsynergyStone().

Definition at line 335 of file window_messages.c.

mnFieldMessageShowCentered

void mnFieldMessageShowCentered(Sint32 msg, Sint32 mode, Sint32 yOffset)

Shows a message centred across the screen and in its top 15 rows (yOffset tiles lower), waits until it is typed out and closes it, in the window mode (CENTERED_MESSAGE_MODE) asks for.

References mnMessageAllTyped(), mnMessageDecode(), mnMessageStart(), mnTextGetMessageSize(), mnWindowClose(), mnWindowCreate(), mnWindowIsClosed(), Sint32, state, sySynch() and width.

Referenced by scCottageRoomsBDoraWakesIsaac(), scInit(), scKalayWatchTourGroupDeparture(), scSanctumLeaveAfterRefusing(), scShipRoomsCallLeaderBackToBeasts(), scShipRoomsReportMonstersBelowdecks(), scSolSanctumElementalStarRoomAlexTakesStars(), scSolSanctumElementalStarRoomFelixRemovesMask(), scTolbiShipDeckMonsterLandsOnDeck(), scTolbiShipDeckMonstersAttackCrew(), scTolbiShipDeckMonstersBoard(), scValeMendingTheRoof() and scVenusLighthouseAeriePlayShebasFall().

Definition at line 360 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() and mnPartyShowPairJoinedMessage().

Definition at line 411 of file window_messages.c.

mnMessageFind

void mnMessageFind(MESSAGE_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 mnMessageFindArm, mnMessageFindCodeSize, Sint32 and syHeapRelease().

Referenced by mnMessageDecode() and mnMessageDecodeRaw().

Definition at line 419 of file window_messages.c.

mnTextDecodeSymbolInC

Sint32 mnTextDecodeSymbolInC(MESSAGE_READER *reader)

Unused: decodes the next symbol of a message, as TextDecodeSymbol, the copy the game runs from RAM, does.

References Sint32 and TextMessageContexts.

Definition at line 430 of file window_messages.c.

mnPortraitClearSlots

void mnPortraitClearSlots(void)

Marks both portrait slots free (PORTRAIT_SLOT_EMPTY). Only the field engine's setup calls it.

References Sint32 and state.

Referenced by mnWindowSystemInitField().

Definition at line 526 of file window_messages.c.

mnPortraitGetForSpeaker

Sint32 mnPortraitGetForSpeaker(Uint32 speaker)

Returns the portrait of a character or another speaker's sprite, or -1 when it has none: speakers up to Garet's child sprite take theirs from PortraitCharacterMap, the others from PortraitSpriteMap, numbered from PORTRAIT_SPRITE_MAP_FIRST (mnIconLoadWithPalette takes it as the row PORTRAIT_JUPITER_DJINNI).

References PortraitCharacterMap, PortraitSpriteMap and Sint32.

Referenced by mnDjinnShowJoinedMessage(), mnNameEntryEditMemberName(), mnPartyShowJoinedMessage(), mnPartyShowPairJoinedMessage(), mnPortraitCloseWindow(), mnPortraitCreate(), mnPortraitOpenWindow() and mnPortraitReload().

Definition at line 542 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(), Sint32 and state.

Referenced by dbMenuTestBrowseMessageRange(), mnDebugBrowserPortraits(), mnNameEntryEditMemberName() and scTolbiMeetSearchingSoldiers().

Definition at line 589 of file window_messages.c.

mnPortraitCloseWindow

void mnPortraitCloseWindow(Uint32 speaker)

Closes the window showing a speaker's portrait, if one is open, at once: the portrait slot showing it names its window sprite, the first sprite of its window.

References mnPortraitGetForSpeaker(), mnWindowClose(), Sint32 and state.

Referenced by mnNameEntryEditMemberName().

Definition at line 625 of file window_messages.c.