Minimal "Hello World" text display using hand-coded 2bpp font tiles. More...
#include <snes.h>Functions | |
| int | main (void) |
| Entry point – set up PPU, load font, build tilemap, display text. | |
Variables | |
| static const u8 | bg_palette [] |
| Background palette in BGR555 format (2 colors, 4 bytes total) | |
| static const u8 | font_tiles [] |
| Hand-coded 2bpp bitmap font tiles (9 glyphs, 16 bytes each) | |
| static const u8 | message [] |
| "HELLO WORLD!" encoded as tile indices into font_tiles[] | |
Minimal "Hello World" text display using hand-coded 2bpp font tiles.
The simplest possible SNES program: writes a hand-coded 2bpp bitmap font into VRAM, builds a tilemap row to spell "HELLO WORLD!", and displays it on BG1 in Mode 0. No external assets or font library are used – every tile is defined as raw bitplane data in a C array, making this example a good starting point for understanding how the SNES PPU interprets tile graphics and tilemaps.
| int main | ( | void | ) |
Entry point – set up PPU, load font, build tilemap, display text.
Initializes the SNES hardware via consoleInit(), loads a hand-coded 2bpp font into VRAM, fills the 32x32 tilemap with blank tiles, writes the "HELLO WORLD!" message at a specific tilemap row/column, and enters an infinite VBlank loop. All VRAM writes happen during forced blank (screen off) to satisfy the PPU timing constraint.
< VRAM word address for tilemap cursor position
< Current tile index read from message[]
< Loop counter for tilemap fill and message write
|
static |
Background palette in BGR555 format (2 colors, 4 bytes total)
SNES CGRAM stores colors as 15-bit BGR555: bbbbbgggggrrrrr in two bytes (little-endian). Color 0 is the background fill, color 1 is the text. Only 2 of the 4 available Mode 0 palette entries are used.
|
static |
Hand-coded 2bpp bitmap font tiles (9 glyphs, 16 bytes each)
Each 8x8 tile occupies 16 bytes in SNES 2bpp format: two interleaved bitplanes per pixel row. Bitplane 0 selects palette color 1, bitplane 1 selects color 2, and both together select color 3. All bitplane-1 bytes are zero here, so every lit pixel maps to palette color 1 (white).
Tile index map: 0=Space, 1=H, 2=E, 3=L, 4=O, 5=W, 6=R, 7=D, 8=!
|
static |
"HELLO WORLD!" encoded as tile indices into font_tiles[]
Each byte is an index into the font tile array. The string is terminated by 0xFF, which acts as an end-of-message sentinel (not a valid tile index).