Skip to Content
The Alchemy Project

src/window/window_borders.c

Window zoom and borders, and opening and waiting on message windows. More…

Included by window.c.

Structures

NameDescription
structWINDOW_ZOOM_SCRATCHScratch values for a stage of a window's zoom: the scaled part of a side, the scaled duration and their ratio.

Macros

NameDescription
#defineTEXT_DEFAULT_LETTER_SPACING 9The pixels between sprite glyphs at a message's start.
#defineGLYPH_TILES_SIZE (WINDOW_SPRITE_COUNT * 4 * TILE_SIZE_4BPP)The glyph tiles' size in sprite VRAM: the four tiles of a 16x16 glyph for each window sprite.
#defineFIELD_MESSAGE_TOP_ROWS 12The tile rows a field message is centred in, from the top of the screen.
#defineTILE_NUMBER_AND_FLIPS (TILE_NUMBER_MASK | TILE_HFLIP | TILE_VFLIP)A tilemap entry's tile number and flip bits, below its palette.

Functions

NameDescription
voidmnWindowUpdateZooms (void)The per-tick window update: advances each window's zoom while it opens or closes, draws it in full once open, and frees its slot once closed.
voidmnWindowDrawZoomBorder (void *windowArg, Sint32 savePos)Draws a zooming window at its size for this tick: the window grows from its centre as zoomStage counts down to 0.
Uint16 *mnMemoryFillHalfwordsDMA (Uint16 *dest, Sint32 value, Sint32 count)Fills count halfwords at dest with value by DMA, and returns the position after them. value holds the halfword in both its halves.
voidmnWindowDrawBorder (Sint32 x, Sint32 y, Uint32 width, Uint32 height)Draws an empty window: a border around a filled interior, at tile (x, y) of width by height tiles, and frees the text tiles the rectangle showed.
voidmnWindowMapTextCanvasTiles ( Sint32 x, Sint32 y, Uint32 width, Uint32 height, Sint32 fullWidth)Maps the text canvas tiles into the interior of a window at tile (x, y).
BoolmnMessageAllTyped (void)Returns 1 when every message has finished its text (or is idle), and 0 while one is still typing.
BoolmnWindowIsClosed (WINDOW *window)Returns 1 when a window is fully closed (its slot free), and 0 while it is open or closing.
voidmnTextResetStyle (void)Resets the style glyphs are drawn in: the default colour, plain, and the default line and letter spacing.
voidmnWindowSystemStartFieldUpdate (void)Reserves the glyph sprites' tiles, resets the text style, starts the ring of decoded text from its beginning and starts the per-tick window update (mnWindowSystemUpdate).
voidmnWindowSystemStartBattleUpdate (Sint32 loadGlyphTiles)Resets the text style and starts the per-tick window update (mnWindowSystemUpdate), reserving the glyph sprites' tiles first when loadGlyphTiles is set.
voidmnBattleMessageClose (void)Closes the battle message window at once, if one is open, and forgets it, so the next battle message (mnBattleMessageOpen) opens a new one.
voidmnBattleMessageOpen (Sint32 msg)Shows a message in the battle message window, opening the window (a full-width text canvas along the bottom of the screen) if it is not open, and returns without waiting.
voidmnBattleMessageShowAndWait (Sint32 msg)Shows a message in the battle message window and waits until it has been typed out.
Sint32mnMessageOpenDecoded (WINDOW *window, Sint32 msg)Types a message into an open window from its top left, keeping the window's size from page to page, with no voice blips.
voidmnMessageSetDecodeFlags (Sint32 flags)Sets the decode flags the next message is decoded with (mnMessageDecode): MESSAGE_DECODE_HALTING_SPEECH makes it halting speech, a short pause before each character, broken off with an ellipsis after the first word; MESSAGE_DECODE_VOICED_SPEECH writes a voiced mark after each kana in English and Japanese.
WINDOW *mnMessageOpenWindow (Sint32 msg, Sint32 x, Sint32 y, Uint32 packed)Opens a window sized to a message near tile (x, y) and starts typing the message into it. packed holds the window options (MESSAGE_WINDOW_ZOOM and the rest) in its low bits and the speaker's voice sound in bits 16 to 27 (MESSAGE_WINDOW_VOICE).
voidmnFieldMessageShow (Sint32 msg, Sint32 flags)Shows a message in a window centred on the screen, waits until it is typed out and closes it, as its FIELD_MESSAGE_FLAG flags say.
voidmnWindowSystemUpdate (void)The window system's per-tick event: windows, then messages, then sprite animation.

Description

Window zoom and borders, and opening and waiting on message windows. Part of window.c.

Macros in detail

TEXT_DEFAULT_LETTER_SPACING

#define TEXT_DEFAULT_LETTER_SPACING 9

The pixels between sprite glyphs at a message's start.

Referenced by mnTextResetStyle(), mnWindowSystemStartBattleUpdate() and mnWindowSystemStartFieldUpdate().

Definition at line 5 of file window_borders.c.

GLYPH_TILES_SIZE

#define GLYPH_TILES_SIZE (WINDOW_SPRITE_COUNT * 4 * TILE_SIZE_4BPP)

The glyph tiles' size in sprite VRAM: the four tiles of a 16x16 glyph for each window sprite.

Referenced by mnWindowSystemStartBattleUpdate() and mnWindowSystemStartFieldUpdate().

Definition at line 9 of file window_borders.c.

FIELD_MESSAGE_TOP_ROWS

#define FIELD_MESSAGE_TOP_ROWS 12

The tile rows a field message is centred in, from the top of the screen.

Referenced by mnFieldMessageShow().

Definition at line 12 of file window_borders.c.

TILE_NUMBER_AND_FLIPS

#define TILE_NUMBER_AND_FLIPS (TILE_NUMBER_MASK | TILE_HFLIP | TILE_VFLIP)

A tilemap entry's tile number and flip bits, below its palette.

Referenced by mnWindowMapTextCanvasTiles().

Definition at line 15 of file window_borders.c.

Functions in detail

mnWindowUpdateZooms

void mnWindowUpdateZooms(void)

The per-tick window update: advances each window's zoom while it opens or closes, draws it in full once open, and frees its slot once closed.

References mnWindowDrawOpened(), mnWindowDrawZoomBorder(), mnWindowEraseBorderRect() and Sint32.

Referenced by mnWindowSystemUpdate().

Definition at line 28 of file window_borders.c.

mnWindowDrawZoomBorder

void mnWindowDrawZoomBorder(void *windowArg, Sint32 savePos)

Draws a zooming window at its size for this tick: the window grows from its centre as zoomStage counts down to 0.

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

Referenced by mnWindowUpdateZooms().

Definition at line 104 of file window_borders.c.

mnMemoryFillHalfwordsDMA

Uint16 *mnMemoryFillHalfwordsDMA(Uint16 *dest, Sint32 value, Sint32 count)

Fills count halfwords at dest with value by DMA, and returns the position after them. value holds the halfword in both its halves.

References Sint32.

Referenced by mnWindowDrawBorder().

Definition at line 153 of file window_borders.c.

mnWindowDrawBorder

void mnWindowDrawBorder(Sint32 x, Sint32 y, Uint32 width, Uint32 height)

Draws an empty window: a border around a filled interior, at tile (x, y) of width by height tiles, and frees the text tiles the rectangle showed.

References mnMemoryFillHalfwordsDMA(), mnWindowClearTextTilesInRect(), Sint32, state and width.

Referenced by mnMessageType(), mnPartyStatusDraw(), mnWindowDrawOpened(), mnWindowDrawZoomBorder(), mnWindowSpriteRedrawSavedRect() and mnWindowStepSwellEffect().

Definition at line 165 of file window_borders.c.

mnWindowMapTextCanvasTiles

void mnWindowMapTextCanvasTiles( Sint32 x, Sint32 y, Uint32 width, Uint32 height, Sint32 fullWidth)

Maps the text canvas tiles into the interior of a window at tile (x, y). With fullWidth set the canvas covers the side border columns too.

References Sint32, state and width.

Referenced by mnBattleMessageOpen(), mnBattleStatusScreenRun() and mnWindowDrawOpened().

Definition at line 214 of file window_borders.c.

mnMessageAllTyped

Bool mnMessageAllTyped(void)

Returns 1 when every message has finished its text (or is idle), and 0 while one is still typing.

References Sint32.

Referenced by dbMenuTestShowMessageAndWait(), mnBattleCollectPartyCommands(), mnBattleMessageShowAndWait(), mnFieldMessageShow(), mnFieldMessageShowCentered(), mnMessageShowAndWait(), mnSaveConfirmAndWriteLinkTallies(), mnSaveEraseSelectedFile(), mnSaveToChosenFile(), scBattleArenaSaveBattleResults() and scBattleArenaSaveMonsterBattleResults().

Definition at line 259 of file window_borders.c.

mnWindowIsClosed

Bool mnWindowIsClosed(WINDOW *window)

Returns 1 when a window is fully closed (its slot free), and 0 while it is open or closing.

Referenced by mnFieldMessageShow(), mnFieldMessageShowCentered() and mnReleaseSelectionState().

Definition at line 275 of file window_borders.c.

mnTextResetStyle

void mnTextResetStyle(void)

Resets the style glyphs are drawn in: the default colour, plain, and the default line and letter spacing.

References state.

Referenced by mnTextDrawWideStringAtOffset() and mnWindowCreate().

Definition at line 290 of file window_borders.c.

mnWindowSystemStartFieldUpdate

void mnWindowSystemStartFieldUpdate(void)

Reserves the glyph sprites' tiles, resets the text style, starts the ring of decoded text from its beginning and starts the per-tick window update (mnWindowSystemUpdate).

References mnWindowSystemUpdate(), state, sySetEvent() and syVRAMCacheLoad().

Referenced by mnWindowSystemInitField().

Definition at line 304 of file window_borders.c.

mnWindowSystemStartBattleUpdate

void mnWindowSystemStartBattleUpdate(Sint32 loadGlyphTiles)

Resets the text style and starts the per-tick window update (mnWindowSystemUpdate), reserving the glyph sprites' tiles first when loadGlyphTiles is set.

References mnWindowSystemUpdate(), Sint32, state, sySetEvent() and syVRAMCacheLoad().

Referenced by mnWindowSystemInitBattle().

Definition at line 322 of file window_borders.c.

mnBattleMessageClose

void mnBattleMessageClose(void)

Closes the battle message window at once, if one is open, and forgets it, so the next battle message (mnBattleMessageOpen) opens a new one.

References mnWindowClose().

Definition at line 339 of file window_borders.c.

mnBattleMessageOpen

void mnBattleMessageOpen(Sint32 msg)

Shows a message in the battle message window, opening the window (a full-width text canvas along the bottom of the screen) if it is not open, and returns without waiting.

References mnBattleMessageContinue(), mnMessageDecode(), mnWindowClose(), mnWindowCreate(), mnWindowMapTextCanvasTiles(), Sint32 and state.

Referenced by mnBattleMessageShowAndWait().

Definition at line 354 of file window_borders.c.

mnBattleMessageShowAndWait

void mnBattleMessageShowAndWait(Sint32 msg)

Shows a message in the battle message window and waits until it has been typed out.

References mnBattleMessageOpen(), mnMessageAllTyped(), Sint32 and sySynch().

Definition at line 405 of file window_borders.c.

mnMessageOpenDecoded

Sint32 mnMessageOpenDecoded(WINDOW *window, Sint32 msg)

Types a message into an open window from its top left, keeping the window's size from page to page, with no voice blips.

References mnMessageDecode(), mnMessageStart(), Sint32 and state.

Definition at line 415 of file window_borders.c.

mnMessageSetDecodeFlags

void mnMessageSetDecodeFlags(Sint32 flags)

Sets the decode flags the next message is decoded with (mnMessageDecode): MESSAGE_DECODE_HALTING_SPEECH makes it halting speech, a short pause before each character, broken off with an ellipsis after the first word; MESSAGE_DECODE_VOICED_SPEECH writes a voiced mark after each kana in English and Japanese.

References Sint32 and state.

Definition at line 442 of file window_borders.c.

mnMessageOpenWindow

WINDOW *mnMessageOpenWindow(Sint32 msg, Sint32 x, Sint32 y, Uint32 packed)

Opens a window sized to a message near tile (x, y) and starts typing the message into it. packed holds the window options (MESSAGE_WINDOW_ZOOM and the rest) in its low bits and the speaker's voice sound in bits 16 to 27 (MESSAGE_WINDOW_VOICE).

References mnMessageDecode(), mnMessageStart(), mnWindowClose(), mnWindowCreate(), mnWindowFitOnScreen(), Sint32, state and width.

Referenced by dbMenuTestShowMessageAndWait(), mnFieldMessageShow(), mnMessageShowAndWait(), mnSaveConfirmAndWriteLinkTallies(), mnSaveEraseSelectedFile(), scBattleArenaEnterBattle(), scBattleArenaSaveBattleResults(), scBattleArenaSaveMonsterBattleResults() and scTolbiMeetSearchingSoldiers().

Definition at line 464 of file window_borders.c.

mnFieldMessageShow

void mnFieldMessageShow(Sint32 msg, Sint32 flags)

Shows a message in a window centred on the screen, waits until it is typed out and closes it, as its FIELD_MESSAGE_FLAG flags say.

References fdActorGetScreenPosStub(), MainRoutineStateWork, mnMessageAllTyped(), mnMessageOpenWindow(), mnTextGetMessageSize(), mnWindowClose(), mnWindowIsClosed(), Sint32, state, sySynch() and width.

Referenced by dbMenuTestDamageAndAfflictParty(), dbMenuTestGiveConsumableTestStock(), dbMenuTestGiveEquipmentTestStock(), dbMenuTestGivePartyDjinn(), dbMenuTestGiveTreasureTestStock(), dbMenuTestRaisePartyLevels(), mnMessageShowCentered(), mnPauseMenuRun(), mnSaveChooseAndLoadFile(), mnSaveConfirmAndWriteLinkTallies(), mnSaveCopyFile(), mnSaveEraseSelectedFile(), mnSaveToChosenFile(), mnSaveWriteCurrentFile(), mnSaveWriteFile(), mnSaveWriteLinkTallies(), scAlpineCrossingReadSignpost(), scAltinPeakFlipPoolRoomSwitch(), scAltinPeakFlipSecondWaterBeastRoomSwitch(), scAltinPeakFlipSpritzRoomSwitch(), scAltinPeakFlipThirdWaterBeastRoomSwitch(), scAltinPeakReadFallingRockSign(), scBabiLighthouseInspectLockedDoor(), scBabiLighthouseInspectTruthDoorSwitch(), scBabiPalaceExamineWell(), scBilibinInspectHumanShapedTree(), scBilibinInspectWell(), scBilibinJillGivesHardNut(), scBilibinReadOffLimitsSign(), scBilibinReadWarehouseSign(), scColossoTakePrize(), scCottageRoomsAGiveFarewellHerb(), scCottageRoomsBTalkToDora(), scCrossboneIsleSteppingStonesFlipWaterSwitch(), scFuchinFallsCaveReadDragonFlameInscription(), scFuchinFallsCaveReadKiInscription(), scFuchinFallsCaveReadShadowInscription(), scFuchinFallsCaveSearchDragonStatue(), scFuchinTempleOpenLockedDoor(), scInit(), scKalaySearchWell(), scKolimaForestFloodgateFlipFloodgateSwitch(), scKolimaForestTreeRestoreTret(), scLamaTempleReadWallWriting(), scLogRoomsAFreeVillagerAndFightThieves(), scLogRoomsAIvanJoinsRodSearch(), scLogRoomsAReturnStolenGoods(), scLogRoomsASearchEmptyBarrel(), scLogRoomsASearchEmptyChest(), scLunpaFortressFindHammet() and 49 more.

Definition at line 513 of file window_borders.c.

mnWindowSystemUpdate

void mnWindowSystemUpdate(void)

The window system's per-tick event: windows, then messages, then sprite animation.

References mnMessageUpdateAll(), mnWindowSpriteUpdateAll() and mnWindowUpdateZooms().

Referenced by mnWindowSystemStartBattleUpdate() and mnWindowSystemStartFieldUpdate().

Definition at line 597 of file window_borders.c.