src/window/glyph_arm.c
The text canvas renderer, which runs as ARM code from a copy in RAM: mnGlyphDraw copies it into RAM for each call (RAM_CODE_LOAD), into IWRAM when the copy fits: its 32-bit bus fetches an ARM instruction in one read, where the cartridge's 16-bit bus takes two. More…
#include "window/glyph_arm.h"#include "edition.h"#include "types.h"#include "graphics/glyph.h"#include "graphics/graphics.h"#include "system/definitions.h"#include "window/text_font.h"#include "window/window.h"
Macros
| Name | Description | |
|---|---|---|
#define | TEXT_CANVAS_PIXEL_HEIGHT 32 | The pixel rows text may reach: four tiles, the battle message window's interior; a glyph is cut off below it. |
#define | FONT_FIRST_CODE ' ' | The fonts start at the space. |
#define | ENGLISH_FONT_LAST_CODE 143 | In English, the last code the main font has a glyph for. |
#define | FONT_GLYPH_BYTES ((1 + FONT_GLYPH_ROWS) * 2) | A main-font glyph's bytes, as GLYPH lays one out: its width, then its rows, a halfword each. |
#define | MAIN_FONT_GLYPH_ROWS 12 | The rows of a main-font glyph mnGlyphDrawArm draws, and the Japanese font's glyph size: a width and 12 rows. |
#define | MAIN_FONT_GLYPH_BYTES ((1 + MAIN_FONT_GLYPH_ROWS) * 2) | |
#define | SMALL_FONT_ROWS 10 | The Japanese small font's rows: a byte each. |
#define | PIXELS_4BPP_HALFWORD (color) ((color) * 0x1111) | A halfword of four 4-bit pixels, all colour color: what mnTextSetCanvasPixel masks one pixel out of. |
Functions
| Name | Description | |
|---|---|---|
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. |
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. |
Description
The text canvas renderer, which runs as ARM code from a copy in RAM:
mnGlyphDraw copies it into RAM for each call (RAM_CODE_LOAD), into IWRAM when
the copy fits: its 32-bit bus fetches an ARM instruction in one read, where
the cartridge's 16-bit bus takes two.
A text window draws its text into a canvas of 4bpp tiles in VRAM
(TEXT_CANVAS_VRAM, mapped by mnWindowMapTextCanvasTiles). 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, the battle message window's interior; a glyph is cut off below it.
Referenced by mnGlyphDrawArm().
Definition at line 22 of file glyph_arm.c.
FONT_FIRST_CODE
#define FONT_FIRST_CODE ' '
The fonts start at the space.
Referenced by mnGlyphDrawArm().
Definition at line 24 of file glyph_arm.c.
ENGLISH_FONT_LAST_CODE
#define ENGLISH_FONT_LAST_CODE 143
In English, the last code the main font has a glyph for.
Referenced by mnGlyphDrawArm().
Definition at line 26 of file glyph_arm.c.
FONT_GLYPH_BYTES
#define FONT_GLYPH_BYTES ((1 + FONT_GLYPH_ROWS) * 2)
A main-font glyph's bytes, as GLYPH lays one out: its width, then its rows, a
halfword each.
Definition at line 29 of file glyph_arm.c.
MAIN_FONT_GLYPH_ROWS
#define MAIN_FONT_GLYPH_ROWS 12
The rows of a main-font glyph mnGlyphDrawArm draws, and the Japanese font's
glyph size: a width and 12 rows. Only the Japanese edition draws main-font
characters here; the others always pass a font (mnGlyphDraw), and the
main-font path they keep still reads the Japanese layout.
Referenced by mnGlyphDrawArm().
Definition at line 34 of file glyph_arm.c.
MAIN_FONT_GLYPH_BYTES
#define MAIN_FONT_GLYPH_BYTES ((1 + MAIN_FONT_GLYPH_ROWS) * 2)
Referenced by mnGlyphDrawArm().
Definition at line 35 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 37 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 40 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 45 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: in Japanese
SMALL_FONT_ROWS rows of a bit a pixel, elsewhere the 8x8 characters of the
window tiles. With no font, which only the Japanese edition passes, 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.
In Japanese a kana mark sits over the character before it and advances 0; in
English a code past ENGLISH_FONT_LAST_CODE draws nothing and advances 1.
References FontGlyphs, FontKanjiGlyphs, mnTextSetCanvasPixel() and Sint32.
Referenced by mnGlyphDraw().
Definition at line 78 of file glyph_arm.c.