Skip to Content
The Alchemy Project

src/window/window_text_tiles.c

Text drawn as tiles, text tile ownership and divider lines. More…

Included by window.c.

Macros

NameDescription
#defineTILE_TEXT_NEWLINE_WIDTH JAPANESE_OR(8, FontGlyphWidths[0])A new line in tile text advances by a space's width: tile text is one line.
#defineTILE_TEXT_CANVAS_WIDTH 256Tile text is drawn into a canvas of one byte a pixel, a tile tall, then packed into 4bpp tiles in place: row row of its tile tile is then a word of eight pixels.
#defineTILE_TEXT_CANVAS_SIZE (TILE_TEXT_CANVAS_WIDTH * 8)
#defineTILE_TEXT_PACKED_ROW (tile, row)
#defineTILE_TEXT_NARROW_LAST 128In Japanese, the codes above TILE_TEXT_NARROW_LAST (the kana) are a whole tile wide; a kana's mark is drawn from a tile glyph of its own, the last two of the window tiles, three pixels wide and three pixels back over its kana.
#defineTILE_TEXT_VOICED_MARK_GLYPH 254
#defineTILE_TEXT_SEMIVOICED_MARK_GLYPH 255
#defineTILE_TEXT_MARK_WIDTH 3
#definePIXEL_4BPP_MASK (PALETTE_COLORS - 1)A 4bpp pixel: the low four bits of a byte, the colour of its palette.
#defineTEXT_TILE_TAKEN 1A text tile's bits in WIN_STATE.textTileState; 0 is free.
#defineTEXT_TILE_SHOWN 2seen on the tilemap by mnWindowMarkVisibleTextTiles
#defineTEXT_TILE_STATE_INDEX (tile) (((tile) & 0xFF) ^ TEXT_TILE_FIRST)A text tile's place in WIN_STATE.textTileState: the TEXT_TILES tiles from TEXT_TILE_FIRST take the first places, those from TEXT_EXTRA_TILE_FIRST the next TEXT_TILES.

Functions

NameDescription
voidmnWindowOverlayTilePattern (Uint16 *entry, Uint16 *mirror, Sint32 pattern, Uint8 *remap)Unused: draws window tile pattern over the tile of tilemap entry *entry, its colours mapped through remap (0 leaves a pixel as it was), first giving the entry (and the same entry in mirror) a text tile of its own.
Sint32mnTextDrawStringAsTiles (Uint16 *text, Uint16 *tiles, Uint16 *mirror, Sint32 x)Draws a string of 16-bit character codes with the window font into tiles of their own, starting x pixels into the first tile, and points tiles (and the same entries in mirror) at them.
voidmnWindowClearTextTilesInRect (Sint32 x, Sint32 y, Uint32 width, Uint32 height)Frees the text tiles under a tilemap rectangle (x, y, width and height in tiles) for reuse: their taken and shown bits are cleared.
voidmnWindowMarkVisibleTextTiles (void)Marks the text tiles the tilemap shows, and frees those it no longer shows: a tile taken but not marked shown (its state exactly TEXT_TILE_TAKEN).
voidmnTextUseExtraTiles (Sint32 allowAlternateTiles)Frees the text tiles of the second range (the TEXT_TILES tiles from TEXT_EXTRA_TILE_FIRST), and with allowAlternateTiles set lets text take that range too; the first range's tiles keep their state.
voidmnWindowReservedNoOperation (void)Unused: an empty function between the text tiles and the dividers.
voidmnWindowDrawDividerLine ( WINDOW *window, Uint32 x1, Uint32 y1, Uint32 x2, Uint32 y2)Draws a straight divider line inside a window from tile (x1, y1) to (x2, y2), horizontal or vertical: its ends join the tick or the lines they meet, and it crosses the lines it passes over.
voidmnTextSetColor (Sint32 color)Sets the colour (TEXT_COL) text is drawn in.
voidmnTextSetStyle (Uint16 style)Sets the style (TXT_STYLE) text is drawn in.
voidmnTextDrawMessage (Sint32 msg, WINDOW *window, Sint32 x, Sint32 y)Decodes a message and draws it into a text canvas window at pixel (x, y), all at once.
voidmnTextDrawMessageAsTiles (Sint32 msg, const WINDOW *window, Uint32 offsetX, Uint32 offsetY)Decodes a message and draws it as tiles in a window at pixel (offsetX, offsetY) of its interior. offsetY is rounded down to a tile row; offsetX picks the tile, and its remainder is where the text starts in it.
static __inline__ voidmnTextWidenByteString (const Uint8 *input, Uint16 *output)Copies a zero-terminated byte string into the text renderer's halfwords.
voidmnTextDrawString (const Uint8 *text, WINDOW *window, Sint32 x, Sint32 y)Draws a byte string into a text canvas window at pixel (x, y).
voidmnTextDrawStringAtOffset (const Uint8 *text, const WINDOW *window, Sint32 offsetX, Sint32 offsetY)Draws a byte string as tiles in a window at pixel (offsetX, offsetY) of its interior.
voidmnTextDrawStringInWindow (const Uint8 *text, WINDOW *window, Uint32 x, Uint32 y)Draws a byte string into a window's tilemap at pixel (x, y) of its interior, rounded down to tiles.
voidmnTextDrawNumber ( Sint32 value, Sint32 width, WINDOW *window, Sint32 x, Sint32 y)Draws a number (width as mnStringFormatNumber) into a text canvas window at pixel (x, y).
voidmnTextDrawNumberAtOffset ( Sint32 value, Sint32 width, const WINDOW *window, Sint32 x, Sint32 y)Draws a number (width as mnStringFormatNumber) as tiles in a window at pixel (x, y) of its interior.
voidmnTextDrawNumberInWindow ( Sint32 value, Sint32 width, WINDOW *window, Sint32 x, Sint32 y)Draws a number (width as mnStringFormatNumber) into a window's tilemap at pixel (x, y) of its interior.
voidmnTextDrawPrefixedNumberAtOffset (Sint32 value, const WINDOW *window, Sint32 offsetX, Sint32 offsetY, Sint32 variant)Draws a four-digit number after a two-tile label as tiles in a window at pixel (offsetX, offsetY) of its interior: the HP label (WINDOW_TILE_HP_LABEL and WINDOW_TILE_HP_LABEL_END) for variant 0, the party status window's HP; the PP label (WINDOW_TILE_PP_LABEL and WINDOW_TILE_PP_LABEL_END) for variant 1, its PP.

Description

Text drawn as tiles, text tile ownership and divider lines. Part of window.c.

Macros in detail

TILE_TEXT_NEWLINE_WIDTH

#define TILE_TEXT_NEWLINE_WIDTH JAPANESE_OR(8, FontGlyphWidths[0])

A new line in tile text advances by a space's width: tile text is one line.

Referenced by mnTextDrawStringAsTiles().

Definition at line 4 of file window_text_tiles.c.

TILE_TEXT_CANVAS_WIDTH

#define TILE_TEXT_CANVAS_WIDTH 256

Tile text is drawn into a canvas of one byte a pixel, a tile tall, then packed into 4bpp tiles in place: row row of its tile tile is then a word of eight pixels.

Referenced by mnTextDrawStringAsTiles().

Definition at line 9 of file window_text_tiles.c.

TILE_TEXT_CANVAS_SIZE

#define TILE_TEXT_CANVAS_SIZE (TILE_TEXT_CANVAS_WIDTH * 8)

Referenced by mnTextDrawStringAsTiles().

Definition at line 10 of file window_text_tiles.c.

TILE_TEXT_PACKED_ROW

#define TILE_TEXT_PACKED_ROW(tile, row)

Referenced by mnTextDrawStringAsTiles().

Definition at line 11 of file window_text_tiles.c.

TILE_TEXT_NARROW_LAST

#define TILE_TEXT_NARROW_LAST 128

In Japanese, the codes above TILE_TEXT_NARROW_LAST (the kana) are a whole tile wide; a kana's mark is drawn from a tile glyph of its own, the last two of the window tiles, three pixels wide and three pixels back over its kana.

Referenced by mnTextDrawStringAsTiles().

Definition at line 17 of file window_text_tiles.c.

TILE_TEXT_VOICED_MARK_GLYPH

#define TILE_TEXT_VOICED_MARK_GLYPH 254

Referenced by mnTextDrawStringAsTiles().

Definition at line 18 of file window_text_tiles.c.

TILE_TEXT_SEMIVOICED_MARK_GLYPH

#define TILE_TEXT_SEMIVOICED_MARK_GLYPH 255

Referenced by mnTextDrawStringAsTiles().

Definition at line 19 of file window_text_tiles.c.

TILE_TEXT_MARK_WIDTH

#define TILE_TEXT_MARK_WIDTH 3

Referenced by mnTextDrawStringAsTiles().

Definition at line 20 of file window_text_tiles.c.

PIXEL_4BPP_MASK

#define PIXEL_4BPP_MASK (PALETTE_COLORS - 1)

A 4bpp pixel: the low four bits of a byte, the colour of its palette.

Referenced by mnTextDrawStringAsTiles() and mnWindowOverlayTilePattern().

Definition at line 23 of file window_text_tiles.c.

TEXT_TILE_TAKEN

#define TEXT_TILE_TAKEN 1

A text tile's bits in WIN_STATE.textTileState; 0 is free.

allocated to some text

Referenced by mnTextDrawStringAsTiles(), mnWindowClearTextTilesInRect(), mnWindowMarkVisibleTextTiles() and mnWindowOverlayTilePattern().

Definition at line 26 of file window_text_tiles.c.

TEXT_TILE_SHOWN

#define TEXT_TILE_SHOWN 2

seen on the tilemap by mnWindowMarkVisibleTextTiles

Referenced by mnWindowClearTextTilesInRect() and mnWindowMarkVisibleTextTiles().

Definition at line 27 of file window_text_tiles.c.

TEXT_TILE_STATE_INDEX

#define TEXT_TILE_STATE_INDEX(tile) (((tile) & 0xFF) ^ TEXT_TILE_FIRST)

A text tile's place in WIN_STATE.textTileState: the TEXT_TILES tiles from TEXT_TILE_FIRST take the first places, those from TEXT_EXTRA_TILE_FIRST the next TEXT_TILES.

Referenced by mnWindowClearTextTilesInRect() and mnWindowMarkVisibleTextTiles().

Definition at line 32 of file window_text_tiles.c.

Functions in detail

mnWindowOverlayTilePattern

void mnWindowOverlayTilePattern(Uint16 *entry, Uint16 *mirror, Sint32 pattern, Uint8 *remap)

Unused: draws window tile pattern over the tile of tilemap entry *entry, its colours mapped through remap (0 leaves a pixel as it was), first giving the entry (and the same entry in mirror) a text tile of its own.

References pixels, Sint32, state, syDMAXCopy() and syResourceGetTableEntry().

Definition at line 37 of file window_text_tiles.c.

mnTextDrawStringAsTiles

Sint32 mnTextDrawStringAsTiles(Uint16 *text, Uint16 *tiles, Uint16 *mirror, Sint32 x)

Draws a string of 16-bit character codes with the window font into tiles of their own, starting x pixels into the first tile, and points tiles (and the same entries in mirror) at them.

References FontColorPens, FontGlyphWidths, Sint32, state, syHeapAllocate(), syHeapRelease(), syResourceGetTableEntry(), syWordsClear() and syWordsFill().

Referenced by mnTextDrawMessageAsTiles(), mnTextDrawPrefixedNumberAtOffset(), mnTextDrawStringAtOffset() and mnTextDrawWideStringAsTiles().

Definition at line 115 of file window_text_tiles.c.

mnWindowClearTextTilesInRect

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

Frees the text tiles under a tilemap rectangle (x, y, width and height in tiles) for reuse: their taken and shown bits are cleared.

References Sint32 and width.

Referenced by mnWindowClearInteriorTiles(), mnWindowDrawBorder(), mnWindowDrawDividerLine() and mnWindowEraseBorderRect().

Definition at line 346 of file window_text_tiles.c.

mnWindowMarkVisibleTextTiles

void mnWindowMarkVisibleTextTiles(void)

Marks the text tiles the tilemap shows, and frees those it no longer shows: a tile taken but not marked shown (its state exactly TEXT_TILE_TAKEN).

References Sint32, state and width.

Referenced by mnBattleCollectPartyCommands(), mnBattleDjinnMenuRun() and mnBattleStatusScreenRun().

Definition at line 379 of file window_text_tiles.c.

mnTextUseExtraTiles

void mnTextUseExtraTiles(Sint32 allowAlternateTiles)

Frees the text tiles of the second range (the TEXT_TILES tiles from TEXT_EXTRA_TILE_FIRST), and with allowAlternateTiles set lets text take that range too; the first range's tiles keep their state.

References Sint32 and state.

Referenced by mnBattleDjinnMenuRun().

Definition at line 423 of file window_text_tiles.c.

mnWindowReservedNoOperation

void mnWindowReservedNoOperation(void)

Unused: an empty function between the text tiles and the dividers.

Definition at line 441 of file window_text_tiles.c.

mnWindowDrawDividerLine

void mnWindowDrawDividerLine( WINDOW *window, Uint32 x1, Uint32 y1, Uint32 x2, Uint32 y2)

Draws a straight divider line inside a window from tile (x1, y1) to (x2, y2), horizontal or vertical: its ends join the tick or the lines they meet, and it crosses the lines it passes over.

References mnWindowClearTextTilesInRect() and state.

Referenced by mnBattleDjinnMenuShowChangePreview(), mnBattleStatusScreenRun(), mnDebugSelectShortcuts(), mnDjinnShowJoinedMessage(), mnFileListDrawSummary(), mnFileListSelectFile(), mnNameEntryEditMemberName(), mnPartyShowJoinedMessage(), mnPartyShowPairJoinedMessage(), mnPauseMenuOpen(), mnSettingsMenuOpen() and scInit().

Definition at line 448 of file window_text_tiles.c.

mnTextSetColor

void mnTextSetColor(Sint32 color)

Sets the colour (TEXT_COL) text is drawn in.

References Sint32 and state.

Referenced by mnBattleCollectPartyCommands(), mnBattleDjinnMenuRun(), mnBattleDjinnMenuShowChangePreview(), mnBattleItemMenuRun(), mnBattlePsynergyMenuRun(), mnBattleSummonMenuRun(), mnBattleTargetRunSelection() and mnPartyStatusDraw().

Definition at line 617 of file window_text_tiles.c.

mnTextSetStyle

void mnTextSetStyle(Uint16 style)

Sets the style (TXT_STYLE) text is drawn in.

References state.

Definition at line 625 of file window_text_tiles.c.

mnTextDrawMessage

void mnTextDrawMessage(Sint32 msg, WINDOW *window, Sint32 x, Sint32 y)

Decodes a message and draws it into a text canvas window at pixel (x, y), all at once.

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

Referenced by dbIncreaseItemAndLevelRunLevelEditor(), dbIncreaseItemAndLevelSelectAbility(), dbMenuTestSelectItem(), mnAreaNameWindowShow(), mnDebugSceneSelectDrawRow(), mnFileListSelectFile(), mnIconMenuChooseSendOption(), mnPauseMenuOpen(), mnSettingsMenuRun(), mnTransferMethodDrawHelp(), scInit() and scSanctumChooseRestartOption().

Definition at line 634 of file window_text_tiles.c.

mnTextDrawMessageAsTiles

void mnTextDrawMessageAsTiles(Sint32 msg, const WINDOW *window, Uint32 offsetX, Uint32 offsetY)

Decodes a message and draws it as tiles in a window at pixel (offsetX, offsetY) of its interior. offsetY is rounded down to a tile row; offsetX picks the tile, and its remainder is where the text starts in it.

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

Referenced by dbIncreaseItemAndLevelSelectAbility(), dbIncreaseItemAndLevelSelectItem(), dbMenuTestSelectItem(), mnBattleCollectPartyCommands(), mnBattleCommandRowRun(), mnBattleDjinnMenuRun(), mnBattleDjinnMenuShowChangePreview(), mnBattleItemMenuRun(), mnBattlePsynergyMenuRun(), mnBattleStatusScreenRun(), mnBattleSummonMenuRun(), mnBattleTargetRunSelection(), mnColossoMenuChoose(), mnDebugBrowserPortraits(), mnDebugSelectShortcuts(), mnFileListDrawSummary(), mnIconMenuAnimateTo(), mnIconMenuRun(), mnPasswordLevelDrawHelp(), mnSelectionMenuOpenNameWindow(), mnSettingsMenuOpen(), mnSettingsMenuRun(), scInit(), scKalayTolbiDocksTalkToWomanSellingTickets() and scTolbiSpringRunSpringGame().

Definition at line 647 of file window_text_tiles.c.

mnTextWidenByteString

static __inline__ void mnTextWidenByteString(const Uint8 *input, Uint16 *output)

Copies a zero-terminated byte string into the text renderer's halfwords. The destination needs one halfword per input byte, including the terminator.

Referenced by mnTextDrawString(), mnTextDrawStringAtOffset() and mnTextDrawStringInWindow().

Definition at line 683 of file window_text_tiles.c.

mnTextDrawString

void mnTextDrawString(const Uint8 *text, WINDOW *window, Sint32 x, Sint32 y)

Draws a byte string into a text canvas window at pixel (x, y). The 256-halfword scratch requires at most 255 input bytes before the terminator.

References mnTextDrawWideStringAtOffset(), mnTextWidenByteString(), Sint32, syHeapAllocateEWRAM() and syHeapRelease().

Referenced by mnDebugSceneSelectDrawRow(), mnFileListSelectFile(), mnNameEntryDrawName(), mnNameEntryEditMemberName(), mnTextDrawNumber() and scInit().

Definition at line 696 of file window_text_tiles.c.

mnTextDrawStringAtOffset

void mnTextDrawStringAtOffset(const Uint8 *text, const WINDOW *window, Sint32 offsetX, Sint32 offsetY)

Draws a byte string as tiles in a window at pixel (offsetX, offsetY) of its interior.

References mnTextDrawStringAsTiles(), mnTextWidenByteString(), Sint32, state, syHeapAllocateEWRAM() and syHeapRelease().

Referenced by dbIncreaseItemAndLevelRunLevelEditor(), mnBattleStatusScreenRun(), mnBattleTargetRunSelection(), mnFileListDrawSummary(), mnPartyStatusDraw() and mnTextDrawNumberAtOffset().

Definition at line 708 of file window_text_tiles.c.

mnTextDrawStringInWindow

void mnTextDrawStringInWindow(const Uint8 *text, WINDOW *window, Uint32 x, Uint32 y)

Draws a byte string into a window's tilemap at pixel (x, y) of its interior, rounded down to tiles.

References mnTextDrawWideStringInWindow(), mnTextWidenByteString(), syHeapAllocateEWRAM() and syHeapRelease().

Referenced by dbIncreaseItemAndLevelRunLevelEditor(), dbIncreaseItemAndLevelSelectAbility(), dbIncreaseItemAndLevelSelectItem(), dbIncreaseItemAndLevelShowGlyphCaptions(), dbMenuTestSelectItem(), mnDebugBrowserIcons(), mnDebugFlagEditorDrawTable(), mnFileListDrawSummary(), mnNameEntryEditMemberName() and mnTextDrawNumberInWindow().

Definition at line 745 of file window_text_tiles.c.

mnTextDrawNumber

void mnTextDrawNumber( Sint32 value, Sint32 width, WINDOW *window, Sint32 x, Sint32 y)

Draws a number (width as mnStringFormatNumber) into a text canvas window at pixel (x, y).

References mnStringFormatNumber(), mnTextDrawString(), Sint32 and width.

Referenced by mnDebugSceneSelectDrawRow() and scBattleArenaChooseDebugParamSet().

Definition at line 760 of file window_text_tiles.c.

mnTextDrawNumberAtOffset

void mnTextDrawNumberAtOffset( Sint32 value, Sint32 width, const WINDOW *window, Sint32 x, Sint32 y)

Draws a number (width as mnStringFormatNumber) as tiles in a window at pixel (x, y) of its interior.

References mnStringFormatNumber(), mnTextDrawStringAtOffset(), Sint32 and width.

Referenced by dbIncreaseItemAndLevelSelectAbility(), dbIncreaseItemAndLevelSelectItem(), dbMenuTestSelectItem(), mnBattleCollectPartyCommands(), mnBattleDjinnMenuRun(), mnBattlePsynergyMenuRun(), mnDebugSelectShortcuts(), mnFileListDrawDjinnCounts() and mnFileListDrawSummary().

Definition at line 771 of file window_text_tiles.c.

mnTextDrawNumberInWindow

void mnTextDrawNumberInWindow( Sint32 value, Sint32 width, WINDOW *window, Sint32 x, Sint32 y)

Draws a number (width as mnStringFormatNumber) into a window's tilemap at pixel (x, y) of its interior.

References mnStringFormatNumber(), mnTextDrawStringInWindow(), Sint32 and width.

Referenced by dbIncreaseItemAndLevelRunLevelEditor(), mnBattleDjinnMenuShowChangePreview(), mnBattleMenuUpdate(), mnBattleStatusScreenRun(), mnBattleTargetRunSelection(), mnDebugBrowserIcons(), mnDebugBrowserPortraits(), mnFileListDrawSummary(), scKalayTolbiDocksTalkToWomanSellingTickets() and scTolbiSpringRunSpringGame().

Definition at line 782 of file window_text_tiles.c.

mnTextDrawPrefixedNumberAtOffset

void mnTextDrawPrefixedNumberAtOffset(Sint32 value, const WINDOW *window, Sint32 offsetX, Sint32 offsetY, Sint32 variant)

Draws a four-digit number after a two-tile label as tiles in a window at pixel (offsetX, offsetY) of its interior: the HP label (WINDOW_TILE_HP_LABEL and WINDOW_TILE_HP_LABEL_END) for variant 0, the party status window's HP; the PP label (WINDOW_TILE_PP_LABEL and WINDOW_TILE_PP_LABEL_END) for variant 1, its PP. The number is padded to four places with spaces.

References mnStringFormatNumber(), mnTextDrawStringAsTiles(), Sint32 and state.

Referenced by mnPartyStatusDraw().

Definition at line 796 of file window_text_tiles.c.