Skip to Content
The Alchemy Project

src/window/window_glyphs.c

Characters rendered into tiles, string widths and number formatting. More…

Included by window.c.

Macros

NameDescription
#defineGLYPH_BUFFER_WIDTH 16mnTextDrawGlyphPair draws its glyphs into a buffer of one byte per pixel (syDecompressBitRuns writes a glyph's rows there in a colour), in rows 16 bytes apart, then packs its top 16 rows into 4bpp tiles.
#defineGLYPH_PIXEL (x, y) ((y) * GLYPH_BUFFER_WIDTH + (x))
#defineGLYPH_TILE_WIDTH 8The pixels across a tile, which the packing reads a row at a time.
#defineGLYPH_PAIR_FIRST (code) ((code) & 0xff)The first character of a pair, in the low byte of its code, and the second, in bits 8 to 23.
#defineGLYPH_PAIR_SECOND (code) (((code) << 8) >> 16)
#defineTEXT_PAST_FONT_CODE 64The code a character past the font is measured as: '@' in the font's Latin-1.
#defineMIND_READ_TEXT_COLOR 8The colour of Mind Read's text, which has no shadow.
#defineGLYPH_SHADOW_COLOR 1The colour of a glyph's shadow, a pixel right of and below it.
#defineFONT_GLYPH (n)The main font's glyph n, counted from the space character.
#defineNUMBER_DIGITS 12The digits mnStringFormatNumber writes, in buffer[1] to [12].

Functions

NameDescription
Sint32mnTextDrawGlyphPair (Uint32 code, Uint32 *out)Draws a character into a 16x16-pixel cell of four 4bpp tiles at out: in the text colour over a shadow, or outlined in TEXT_STYLE_OUTLINED, with the kana mark in the code's top two bits above its top right.
Sint32mnTextGetWideStringWidth (Uint16 *text)Returns the width in pixels of a zero-terminated string of 16-bit character codes: 4 for a space, and for other codes up to TEXT_LAST_FONT_CODE the font width, but nothing for the kana marks; 10 for a kanji (any code above it).
voidmnTextDrawWideStringAtOffset (Uint16 *text, WINDOW *window, Sint32 x, Sint32 y)Draws a zero-terminated string of 16-bit character codes into a text canvas window at pixel (x, y), running its colour, outline, line spacing and new line codes; other control codes are skipped with their arguments.
voidmnTextDrawWideStringAsTiles (Uint16 *buf, const WINDOW *window, Sint32 offsetX, Sint32 offsetY)Unused: draws a string of 16-bit character codes as tiles in a window at tile (offsetX, offsetY) of its interior, as mnTextDrawMessageAsTiles draws a message; a NULL string draws the decoded text in WIN_STATE.textBuf.
voidmnTextDrawWideStringInWindow (Sint16 *text, WINDOW *window, Sint32 x, Sint32 y)Draws a zero-terminated string of 16-bit character codes into a window's tilemap at tile (x, y) of its interior, one tile per character, skipping control codes; a NULL text draws the decoded text in WIN_STATE.textBuf.
Uint8 *mnStringFormatNumber (Uint8 *buf, Sint32 input, Sint32 width)Writes input as decimal text into buf (NUMBER_DIGITS + 2 bytes) and returns where the text starts: with width 0, the number alone with its minus sign; otherwise its last width characters, right-aligned in spaces, with no sign.

Variables

NameDescription
Uint8pixels [24 * GLYPH_BUFFER_WIDTH]24 rows, of which the top 16 are packed.
WIN_STATE *state
const Uint8 *glyph
Sint32width
Sint32colour
Sint32shadowColour
Sint32firstIndex
Sint32secondIndex
Uint16secondWidth
Uint8 *pixel
Sint32tileColumn
Sint32tileRow
Sint32line
Sint32pixelsLeft
Uint32tileLine

Description

Characters rendered into tiles, string widths and number formatting. Part of window.c.

Macros in detail

GLYPH_BUFFER_WIDTH

#define GLYPH_BUFFER_WIDTH 16

mnTextDrawGlyphPair draws its glyphs into a buffer of one byte per pixel (syDecompressBitRuns writes a glyph's rows there in a colour), in rows 16 bytes apart, then packs its top 16 rows into 4bpp tiles. A glyph is drawn from row 2, its shadow a pixel right of and below it, and a kana's mark at the top right.

Referenced by mnTextDrawGlyphPair() and pixels.

Definition at line 9 of file window_glyphs.c.

GLYPH_PIXEL

#define GLYPH_PIXEL(x, y) ((y) * GLYPH_BUFFER_WIDTH + (x))

Referenced by mnTextDrawGlyphPair().

Definition at line 10 of file window_glyphs.c.

GLYPH_TILE_WIDTH

#define GLYPH_TILE_WIDTH 8

The pixels across a tile, which the packing reads a row at a time.

Referenced by mnTextDrawGlyphPair().

Definition at line 12 of file window_glyphs.c.

GLYPH_PAIR_FIRST

#define GLYPH_PAIR_FIRST(code) ((code) & 0xff)

The first character of a pair, in the low byte of its code, and the second, in bits 8 to 23.

Definition at line 16 of file window_glyphs.c.

GLYPH_PAIR_SECOND

#define GLYPH_PAIR_SECOND(code) (((code) << 8) >> 16)

Definition at line 17 of file window_glyphs.c.

TEXT_PAST_FONT_CODE

#define TEXT_PAST_FONT_CODE 64

The code a character past the font is measured as: '@' in the font's Latin-1.

Referenced by mnTextDrawWideStringAtOffset().

Definition at line 20 of file window_glyphs.c.

MIND_READ_TEXT_COLOR

#define MIND_READ_TEXT_COLOR 8

The colour of Mind Read's text, which has no shadow.

Referenced by mnTextDrawGlyphPair().

Definition at line 23 of file window_glyphs.c.

GLYPH_SHADOW_COLOR

#define GLYPH_SHADOW_COLOR 1

The colour of a glyph's shadow, a pixel right of and below it.

Referenced by mnTextDrawGlyphPair().

Definition at line 25 of file window_glyphs.c.

FONT_GLYPH

#define FONT_GLYPH(n)

The main font's glyph n, counted from the space character.

Definition at line 242 of file window_glyphs.c.

NUMBER_DIGITS

#define NUMBER_DIGITS 12

The digits mnStringFormatNumber writes, in buffer[1] to [12].

Referenced by mnStringFormatNumber().

Definition at line 525 of file window_glyphs.c.

Functions in detail

mnTextDrawGlyphPair

Sint32 mnTextDrawGlyphPair(Uint32 code, Uint32 *out)

Draws a character into a 16x16-pixel cell of four 4bpp tiles at out: in the text colour over a shadow, or outlined in TEXT_STYLE_OUTLINED, with the kana mark in the code's top two bits above its top right. Returns its width.

References colour, FontGlyphs, FontKanjiGlyphs, FontMarkGlyphCodes, glyph, line, pixel, pixels, pixelsLeft, shadowColour, Sint32, state, syWordsClear(), tileColumn, tileLine, tileRow and width.

Referenced by mnGlyphDraw().

Definition at line 122 of file window_glyphs.c.

mnTextGetWideStringWidth

Sint32 mnTextGetWideStringWidth(Uint16 *text)

Returns the width in pixels of a zero-terminated string of 16-bit character codes: 4 for a space, and for other codes up to TEXT_LAST_FONT_CODE the font width, but nothing for the kana marks; 10 for a kanji (any code above it).

References Sint32 and width.

Referenced by mnBattleTargetRunSelection().

Definition at line 248 of file window_glyphs.c.

mnTextDrawWideStringAtOffset

void mnTextDrawWideStringAtOffset(Uint16 *text, WINDOW *window, Sint32 x, Sint32 y)

Draws a zero-terminated string of 16-bit character codes into a text canvas window at pixel (x, y), running its colour, outline, line spacing and new line codes; other control codes are skipped with their arguments.

References FontGlyphs, mnGlyphDraw(), mnTextResetStyle(), Sint32, state and width.

Referenced by mnBattleCollectPartyCommands(), mnBattleDjinnMenuRun(), mnBattleItemMenuRun(), mnBattlePsynergyMenuRun(), mnBattleRefuseFlee(), mnBattleStatusScreenRun(), mnBattleSummonMenuRun(), mnBattleTargetRunSelection(), mnTextDrawMessage() and mnTextDrawString().

Definition at line 295 of file window_glyphs.c.

mnTextDrawWideStringAsTiles

void mnTextDrawWideStringAsTiles(Uint16 *buf, const WINDOW *window, Sint32 offsetX, Sint32 offsetY)

Unused: draws a string of 16-bit character codes as tiles in a window at tile (offsetX, offsetY) of its interior, as mnTextDrawMessageAsTiles draws a message; a NULL string draws the decoded text in WIN_STATE.textBuf.

References mnTextDrawStringAsTiles(), Sint32 and state.

Definition at line 425 of file window_glyphs.c.

mnTextDrawWideStringInWindow

void mnTextDrawWideStringInWindow(Sint16 *text, WINDOW *window, Sint32 x, Sint32 y)

Draws a zero-terminated string of 16-bit character codes into a window's tilemap at tile (x, y) of its interior, one tile per character, skipping control codes; a NULL text draws the decoded text in WIN_STATE.textBuf.

References mnWindowPutGlyph(), Sint32 and state.

Referenced by mnBattleDjinnMenuShowChangePreview() and mnTextDrawStringInWindow().

Definition at line 459 of file window_glyphs.c.

mnStringFormatNumber

Uint8 *mnStringFormatNumber(Uint8 *buf, Sint32 input, Sint32 width)

Writes input as decimal text into buf (NUMBER_DIGITS + 2 bytes) and returns where the text starts: with width 0, the number alone with its minus sign; otherwise its last width characters, right-aligned in spaces, with no sign.

References Sint32 and width.

Referenced by mnMessageDecode(), mnStringFormatPlayTime(), mnTextDrawNumber(), mnTextDrawNumberAtOffset(), mnTextDrawNumberInWindow() and mnTextDrawPrefixedNumberAtOffset().

Definition at line 531 of file window_glyphs.c.

Variables in detail

pixels

Uint8 pixels[24 * GLYPH_BUFFER_WIDTH]

24 rows, of which the top 16 are packed.

Referenced by fdSpriteComposePicture(), fdSpritePictureCacheLoad(), fdTileMapDrawRowsFromRam(), mnPartyStatusDrawBars(), mnTextDrawGlyphPair(), mnWindowOverlayTilePattern(), scHeatGaugeDraw() and scSolSanctumStatueInitScrollingSprites().

Definition at line 35 of file window_glyphs.c.

state

WIN_STATE *state

Referenced by btAutoBattleRunApproachAttack(), btAutoBattleRunAttackOrItem(), btAutoBattleRunPsynergy(), btCameraApplyPhasedDelta(), btCameraShake(), btCastingImpactEndPrelude(), btEffectAdvanceBg2OnInterval(), btEffectAdvanceScrollOnInterval(), btEffectApplyBg2Reference(), btEffectApplyWindowBlendRegisters(), btEffectArmBg2AffineHBlankDMA(), btEffectArmPaletteHBlankDMA(), btEffectClearTintTimers(), btEffectCountDownBattlerTints(), btEffectCreateSprites(), btEffectDarkenBackgroundStep(), btEffectDrawStreaks(), btEffectEndCanvasLayer(), btEffectOpenCanvasLayer(), btEffectPlaceFormationSprites(), btEffectReadKeysForEnemyTarget(), btEffectRunAnnihilation(), btEffectRunAstralBlast(), btEffectRunAtalanta(), btEffectRunAttackSlash(), btEffectRunBind(), btEffectRunBladeRain(), btEffectRunBolt(), btEffectRunBoreas(), btEffectRunBreak(), btEffectRunBurstShower(), btEffectRunCastingImpact(), btEffectRunCondemn(), btEffectRunCriticalHit(), btEffectRunCurse(), btEffectRunCybele(), btEffectRunDeathPlunge(), btEffectRunDjinnBeams(), btEffectRunDjinnHeal(), btEffectRunDjinniEntrance(), btEffectRunDouse(), btEffectRunDragonCloud(), btEffectRunDragonFire(), btEffectRunDrain(), btEffectRunElementBurst(), btEffectRunElementPillar(), btEffectRunEruption(), btEffectRunFire(), btEffectRunFlare(), btEffectRunFlashingStrike() and 561 more.

Definition at line 36 of file window_glyphs.c.

glyph

const Uint8 *glyph

Referenced by mnBattlePsynergyMenuRun(), mnBattleSummonMenuRun(), mnDebugBrowserPortraits(), mnIconDecode(), mnIconDrawItem(), mnIconDrawMiscellaneous(), mnTextDrawGlyphPair(), mnTextMeasureAllPages(), mnTextMeasureDecoded(), scCottageRoomsBShowMythrilBag(), scFloatNut(), scImilFuchinFallsPlaceDragonsEye(), scInit(), scKalayPrepareTown(), scSanctumRaiseItemIcon(), scSolSanctumElementalStarRoomPresentStarFX() and scSolSanctumEruptionPlayWiseOneRescue().

Definition at line 37 of file window_glyphs.c.

width

Sint32 width

References Sint32.

Referenced by btEffectRunAtalanta(), btEffectRunBladeRain(), btEffectRunCastingImpact(), btEffectRunCybele(), btEffectRunDjinnBeams(), btEffectRunEruption(), btEffectRunFire(), btEffectRunFlare(), btEffectRunFrost(), btEffectRunGaia(), btEffectRunGrowingColumns(), btEffectRunHail(), btEffectRunImpactBurst(), btEffectRunMars(), btEffectRunProcne(), btEffectRunSpire(), btEffectRunTitanBlade(), fdLuckyWheelsSetUpBetting(), fdMapGridCopyMetatileAttributeRect(), fdMapGridCopyMetatileAttributes(), fdMapGridCopyMetatileIndexRect(), fdMapGridCopyMetatileRect(), fdMapGridCopyMetatiles(), fdMapGridCopyMetatilesLayered(), fdMapGridCopyMetatilesTo(), fdMapGridCopyMetatileTilesRect(), fdMapGridPlayMapEdit(), fdMapScreenUpdateMarkers(), fdMessageShowAtActor(), fdSpriteComposePicture(), mnAreaNameWindowShow(), mnBattleTargetRunSelection(), mnBgScreenFillRect(), mnFieldMessageShow(), mnFieldMessageShowCentered(), mnGlyphDraw(), mnIconMenuCenter(), mnIconMenuLayoutIcons(), mnItemMenuShowMessage(), mnMessageOpenWindow(), mnNameEntryEditMemberName(), mnPartyStatusBuildLayoutBounds(), mnPsynergyMenuDrawShortcuts(), mnStatusScreenDrawSelectionCursor(), mnStringFormatNumber(), mnTextDrawGlyphPair(), mnTextDrawNumber(), mnTextDrawNumberAtOffset(), mnTextDrawNumberInWindow(), mnTextDrawNumberRightAligned() and 34 more.

Definition at line 38 of file window_glyphs.c.

colour

Sint32 colour

References Sint32.

Referenced by mnFileListUpdateGlow(), mnPartyStatusDrawBars() and mnTextDrawGlyphPair().

Definition at line 39 of file window_glyphs.c.

shadowColour

Sint32 shadowColour

References Sint32.

Referenced by mnTextDrawGlyphPair().

Definition at line 40 of file window_glyphs.c.

firstIndex

Sint32 firstIndex

References Sint32.

Referenced by mnDjinnMenuRunPreview() and mnFindShortcutEntries().

Definition at line 41 of file window_glyphs.c.

secondIndex

Sint32 secondIndex

References Sint32.

Referenced by mnDjinnMenuRunPreview() and mnFindShortcutEntries().

Definition at line 42 of file window_glyphs.c.

secondWidth

Uint16 secondWidth

Definition at line 43 of file window_glyphs.c.

pixel

Uint8 *pixel

Referenced by BattleEffectAdditiveForward(), BattleEffectAdditiveReverse(), BattleEffectColorForward(), BattleEffectColorReverse(), BattleEffectCopyForward(), BattleEffectCopyReverse(), BattleEffectMax4Forward(), BattleEffectMax4Reverse(), BattleEffectMaxForward(), BattleEffectMaxReverse(), BattleEffectTransparent8Forward(), BattleEffectTransparent8Reverse(), BattleEffectTransparentForward(), BattleEffectTransparentReverse(), btEffectConvertBackgroundToBlueRamp(), btEffectRunQuake(), fdSpriteDissolveStep(), mnGraphicsMergeShiftedTileRows(), mnTextDrawGlyphPair() and scHeatGaugeDraw().

Definition at line 44 of file window_glyphs.c.

tileColumn

Sint32 tileColumn

References Sint32.

Referenced by fdWorldMapDrawMetatileColumn(), fdWorldMapUpdateView(), mnScanlineWindowBuildEdges() and mnTextDrawGlyphPair().

Definition at line 45 of file window_glyphs.c.

tileRow

Sint32 tileRow

References Sint32.

Referenced by btTransitionDrawRows(), fdWorldMapDrawMetatileRow(), fdWorldMapUpdateView(), mnScanlineWindowBuildEdges() and mnTextDrawGlyphPair().

Definition at line 46 of file window_glyphs.c.

line

Sint32 line

References Sint32.

Referenced by btBackgroundShowZoomedPage(), btCameraSetRange(), btEffectRunBoreas(), btEffectRunDouse(), btEffectRunIce(), btEffectRunStarfieldFall(), btEffectRunTorch(), fdLineScrollBuildPage(), fdLuckyWheelsUpdate(), fdMindReadStartRipple(), fdPsynergyUpdateMindReadWave(), fdWorldMapBuildScanlineTable(), fdWorldMapUpdateAffineLines(), mnDjinnMenuDrawStatPreview(), mnTextDrawGlyphPair(), mnTextMeasureAllPages(), mnWindowPutGlyph(), scAltmillerCaveMeetInvisibleBabi(), scCrossboneIsleSteppingStonesJitterBackgroundScroll(), scKolimaForestFloodgateChangeRiverLines() and sySynch().

Definition at line 47 of file window_glyphs.c.

pixelsLeft

Sint32 pixelsLeft

References Sint32.

Referenced by mnTextDrawGlyphPair().

Definition at line 48 of file window_glyphs.c.

tileLine

Uint32 tileLine

Referenced by mnTextDrawGlyphPair().

Definition at line 49 of file window_glyphs.c.