Loading...
Searching...
No Matches
main.c File Reference

Text module validation using textInit / textLoadFont / textPrintAt. More...

#include <snes.h>

Functions

int main (void)
 Entry point – initialize text module and display a test string.
 

Detailed Description

Text module validation using textInit / textLoadFont / textPrintAt.

Exercises the OpenSNES text module, which provides a built-in ASCII font and a buffered tilemap writer. The module maintains an off-screen text buffer; every text writer (textPutChar, textPrint, textPrintAt, ...) sets a dirty flag and the NMI handler DMAs the buffer to VRAM during the next VBlank — no manual flush call is needed. This example loads the default font into VRAM, prints a single string, and displays it on BG1 in Mode 0.

SNES Concepts
  • Text module workflow: textInit() -> textLoadFont() -> textPrintAt() (NMI auto-flushes)
  • BG tilemap and tile base pointer configuration with bgSetMapPtr / bgSetGfxPtr
  • CGRAM palette setup via setColor() for background and text colors
  • Mode 0 (2bpp) used because the built-in font only needs 4 colors
What to Observe
  • Dark blue screen with "TEXT MODULE TEST" displayed in white
  • If only a dark blue screen appears (no text), textPrintAt has a bug
  • If the screen is black, a crash occurred during text module initialization
Modules Used
console, dma, text, background, sprite
See also
text.h, background.h, video.h

Function Documentation

◆ main()

int main ( void  )

Entry point – initialize text module and display a test string.

Demonstrates the OpenSNES text module workflow: textModeInit() sets up hardware + the text engine in one call, textPrintAt() writes characters into the off-screen buffer, and the NMI handler DMAs the buffer to VRAM as a tilemap during the next VBlank. A WaitForVBlank() before setScreenOn() ensures all VRAM writes complete during blanking, preventing PPU corruption on the first frame.

Returns
Never returns (infinite loop).