Skip to Content
The Alchemy Project

src/window/glyph_arm.c

The text canvas renderer, compiled as ARM code and copied to RAM to run, entered in Thumb through mnGlyphDrawCode (glyph_arm_entries.s). More…

Macros

NameDescription
#defineTEXT_CANVAS_PIXEL_HEIGHT 32The pixel rows text may reach: four tiles; a glyph is cut off below it.
#defineFONT_FIRST_CODE ' 'The fonts start at the space.
#defineMAIN_FONT_GLYPH_ROWS 12The rows of a main-font glyph mnGlyphDrawArm draws.
#defineMAIN_FONT_GLYPH_BYTES ((1 + MAIN_FONT_GLYPH_ROWS) * 2)A main-font glyph's bytes, as GLYPH lays one out: its width, then its rows, a halfword each.
#defineSMALL_FONT_ROWS 10The Japanese small font's rows: a byte each.
#definePIXELS_4BPP_HALFWORD (color) ((color) * 0x1111)A halfword of four 4-bit pixels, all colour color: what mnTextSetCanvasPixel masks one pixel out of.

Functions

NameDescription
static __inline__ voidmnTextSetCanvasPixel (Uint32 windowHeight, Uint32 x, Uint32 tileY, Uint32 doubledPixelRow, Uint8 *canvas, Uint32 repeatedColor)Sets one pixel in the column-major text canvas. windowHeight includes the two border rows; doubledPixelRow is twice the row within a tile. repeatedColor holds the colour index in all four nibbles.
Sint32mnGlyphDrawArm ( WINDOW *window, Uint32 character, Uint32 x, Uint32 y, const Uint8 *font)Draws one character into a window's text canvas with its top-left corner at pixel (x, y) of the window's interior, and returns how far the text advances.

Description

The text canvas renderer, compiled as ARM code and copied to RAM to run, entered in Thumb through mnGlyphDrawCode (glyph_arm_entries.s).

A text window draws its text into a canvas of 4bpp tiles in VRAM (TEXT_CANVAS_VRAM). The canvas tiles run down columns: each column of tiles is as tall as the window's interior, which is the window height less its two border rows.

Macros in detail

TEXT_CANVAS_PIXEL_HEIGHT

#define TEXT_CANVAS_PIXEL_HEIGHT 32

The pixel rows text may reach: four tiles; a glyph is cut off below it.

Referenced by mnGlyphDrawArm().

Definition at line 18 of file glyph_arm.c.

FONT_FIRST_CODE

#define FONT_FIRST_CODE ' '

The fonts start at the space.

Referenced by mnGlyphDrawArm().

Definition at line 20 of file glyph_arm.c.

MAIN_FONT_GLYPH_ROWS

#define MAIN_FONT_GLYPH_ROWS 12

The rows of a main-font glyph mnGlyphDrawArm draws. It reads the codes up to TEXT_LAST_FONT_CODE MAIN_FONT_GLYPH_BYTES apart in every edition, the Japanese layout of a width and 12 rows.

Referenced by mnGlyphDrawArm().

Definition at line 24 of file glyph_arm.c.

MAIN_FONT_GLYPH_BYTES

#define MAIN_FONT_GLYPH_BYTES ((1 + MAIN_FONT_GLYPH_ROWS) * 2)

A main-font glyph's bytes, as GLYPH lays one out: its width, then its rows, a halfword each.

Referenced by mnGlyphDrawArm().

Definition at line 27 of file glyph_arm.c.

SMALL_FONT_ROWS

#define SMALL_FONT_ROWS 10

The Japanese small font's rows: a byte each.

Referenced by mnGlyphDrawArm().

Definition at line 29 of file glyph_arm.c.

PIXELS_4BPP_HALFWORD

#define PIXELS_4BPP_HALFWORD(color) ((color) * 0x1111)

A halfword of four 4-bit pixels, all colour color: what mnTextSetCanvasPixel masks one pixel out of.

Referenced by mnGlyphDrawArm().

Definition at line 32 of file glyph_arm.c.

Functions in detail

mnTextSetCanvasPixel

static __inline__ void mnTextSetCanvasPixel(Uint32 windowHeight, Uint32 x, Uint32 tileY, Uint32 doubledPixelRow, Uint8 *canvas, Uint32 repeatedColor)

Sets one pixel in the column-major text canvas. windowHeight includes the two border rows; doubledPixelRow is twice the row within a tile. repeatedColor holds the colour index in all four nibbles.

Referenced by mnGlyphDrawArm().

Definition at line 37 of file glyph_arm.c.

mnGlyphDrawArm

Sint32 mnGlyphDrawArm( WINDOW *window, Uint32 character, Uint32 x, Uint32 y, const Uint8 *font)

Draws one character into a window's text canvas with its top-left corner at pixel (x, y) of the window's interior, and returns how far the text advances.

With font set, the character comes from that small font: the 10-row, 1bpp kana and numeral font in Japanese, or an 8x8 two-colour font elsewhere, 32 bytes a character. With no font, it comes from the main font (FontGlyphs, and in Japanese FontKanjiGlyphs from KANJI_FIRST_CODE), drawn in four passes: the first three draw an outline in colour 5 (offset left, right and down when the window has WINDOW_FLAG_OUTLINED_TEXT) and the last draws the glyph itself in colour 1. Kana marks (TEXT_MARK_VOICED and TEXT_MARK_SEMIVOICED) sit over the previous character and advance by 0.

References FontGlyphs, FontKanjiGlyphs, mnTextSetCanvasPixel() and Sint32.

Definition at line 69 of file glyph_arm.c.