Font Test

Source: src/font_test.c · 68 lines · 4 functions.

Screen / module overview

  1. Enter Font Test

    Set running and select the normal page.

  2. A / K next page

    Alternate between normal and reverse PET glyph pages.

  3. Draw the page

    Clear black. Draw all 256 glyphs in a 32-column grid with page heading and controls.

  4. Repeat or stop

    Continue displaying the selected page until the screen is stopped.

Module entry points

These functions are exposed to the rest of the project. Open one to follow its decisions and the helpers it calls.

How to read these diagrams

Each function has its own expandable diagram using the actual expressions and statements from this file. Decisions split into True and False; loop bodies are indented. Returns end the function immediately; break and continue follow their C meanings. Arrows between statements show their order when execution reaches them.

These are structural source diagrams before preprocessing, not runtime traces. Conditional compilation and macros remain source expressions. Ternary choices remain inside their statement. Calls are linked separately; callback execution and task scheduling are not inferred.

Functions in this file

startFontTest() · source line 21
void startFontTest(void)
  1. Executerunning = true;
  2. Executepage = 0U;
Read original function source
void startFontTest(void)
{
    running = true;
    page = 0U;
}
stopFontTest() · source line 27
void stopFontTest(void)
  1. Executerunning = false;
Read original function source
void stopFontTest(void)
{
    running = false;
}
fontTestAction() · source line 32
void fontTestAction(bool next_page)
  1. Decision!running || !next_page
    True
    1. Exit this functionreturn;
    False

    Continue after this decision.

  2. Executepage = (page + 1U) % FONT_TEST_PAGE_COUNT;
Read original function source
void fontTestAction(bool next_page)
{
    if (!running || !next_page) return;
    page = (page + 1U) % FONT_TEST_PAGE_COUNT;
}
drawFontTest() · source line 38
void drawFontTest(uint16_t *frame)

Calls into this documentation:

  1. Decision!running || frame == NULL
    True
      1. Exit this functionreturn;
    False

    Continue after this decision.

  2. Executeclear(frame, COLOR_BLACK);
  3. Executeconst bool reverse = page != 0U;
  4. Executechar heading[32];
  5. Executesnprintf(heading, sizeof(heading), "PET 00-FF %s", reverse ? "REVERSE" : "NORMAL");
  6. Executedraw_text_centred(frame, LCD_WIDTH / 2, 5, heading, 2, COLOR_CYAN);
  7. Executedraw_text_centred(frame, LCD_WIDTH / 2, 27, "32 X 8 8X8 GLYPHS", 1, COLOR_LIGHTGRAY);
  8. FOR loopunsigned offset = 0U; offset < FONT_TEST_GLYPHS_PER_PAGE; ++offset

    Repeat body while the loop condition permits; then continue below.

      1. Executeconst unsigned glyph = offset;
      2. Executeconst unsigned column = offset % FONT_TEST_COLUMNS;
      3. Executeconst unsigned row = offset / FONT_TEST_COLUMNS;
      4. Executeconst int x = (int)FONT_TEST_GRID_LEFT + (int)(column * PET2001_FONT_GLYPH_WIDTH);
      5. Executeconst int y = (int)FONT_TEST_GRID_TOP + (int)(row * PET2001_FONT_GLYPH_HEIGHT);
      6. ExecutedrawPet2001Glyph(frame, x, y, (uint8_t)glyph, reverse, COLOR_LIGHTGRAY, COLOR_BLACK, 1);
  9. Executesnprintf(heading, sizeof(heading), "%u/%u A/K NEXT", page + 1U, FONT_TEST_PAGE_COUNT);
  10. Executedraw_text_centred(frame, LCD_WIDTH / 2, 141, heading, 1, COLOR_CYAN);
  11. Executedraw_text_centred(frame, LCD_WIDTH / 2, 157, "BOOT BACK", 1, COLOR_LIGHTGRAY);
Read original function source
void drawFontTest(uint16_t *frame)
{
    if (!running || frame == NULL) {
        return;
    }

    clear(frame, COLOR_BLACK);
    const bool reverse = page != 0U;
    char heading[32];
    snprintf(heading, sizeof(heading), "PET 00-FF %s", reverse ? "REVERSE" : "NORMAL");
    draw_text_centred(frame, LCD_WIDTH / 2, 5, heading, 2, COLOR_CYAN);
    draw_text_centred(frame, LCD_WIDTH / 2, 27, "32 X 8  8X8 GLYPHS", 1, COLOR_LIGHTGRAY);

    for (unsigned offset = 0U; offset < FONT_TEST_GLYPHS_PER_PAGE; ++offset) {
        const unsigned glyph = offset;
        const unsigned column = offset % FONT_TEST_COLUMNS;
        const unsigned row = offset / FONT_TEST_COLUMNS;
        const int x = (int)FONT_TEST_GRID_LEFT +
            (int)(column * PET2001_FONT_GLYPH_WIDTH);
        const int y = (int)FONT_TEST_GRID_TOP +
            (int)(row * PET2001_FONT_GLYPH_HEIGHT);
        drawPet2001Glyph(frame, x, y, (uint8_t)glyph, reverse,
                          COLOR_LIGHTGRAY, COLOR_BLACK, 1);
    }

    snprintf(heading, sizeof(heading), "%u/%u  A/K NEXT", page + 1U, FONT_TEST_PAGE_COUNT);
    draw_text_centred(frame, LCD_WIDTH / 2, 141, heading, 1, COLOR_CYAN);
    draw_text_centred(frame, LCD_WIDTH / 2, 157, "BOOT BACK", 1, COLOR_LIGHTGRAY);
}
Complete original file, including constants and data
/* Coded By JD(2026) */
#error "Reference listing only — not provided as build-ready source."
#include "font_test.h"

#include <stdio.h>

#include "PET2001_font.h"
#include "game_colors.h"
#include "game_graphics.h"

#define FONT_TEST_COLUMNS 32U
#define FONT_TEST_GLYPHS_PER_PAGE PET2001_FONT_GLYPH_COUNT
#define FONT_TEST_PAGE_COUNT 2U
#define FONT_TEST_ROWS (FONT_TEST_GLYPHS_PER_PAGE / FONT_TEST_COLUMNS)
#define FONT_TEST_GRID_WIDTH (FONT_TEST_COLUMNS * PET2001_FONT_GLYPH_WIDTH)
#define FONT_TEST_GRID_HEIGHT (FONT_TEST_ROWS * PET2001_FONT_GLYPH_HEIGHT)
#define FONT_TEST_GRID_LEFT ((LCD_WIDTH - FONT_TEST_GRID_WIDTH) / 2U)
#define FONT_TEST_GRID_TOP 45U

static bool running;
static unsigned page;

void startFontTest(void)
{
    running = true;
    page = 0U;
}

void stopFontTest(void)
{
    running = false;
}

void fontTestAction(bool next_page)
{
    if (!running || !next_page) return;
    page = (page + 1U) % FONT_TEST_PAGE_COUNT;
}

void drawFontTest(uint16_t *frame)
{
    if (!running || frame == NULL) {
        return;
    }

    clear(frame, COLOR_BLACK);
    const bool reverse = page != 0U;
    char heading[32];
    snprintf(heading, sizeof(heading), "PET 00-FF %s", reverse ? "REVERSE" : "NORMAL");
    drawPet2001TextCentredTransparent(frame, LCD_WIDTH / 2, 5, heading, COLOR_CYAN, 2);
    drawPet2001TextCentredTransparent(frame, LCD_WIDTH / 2, 27, "32 X 8  8X8 GLYPHS",
                                       COLOR_LIGHTGRAY, 1);

    for (unsigned offset = 0U; offset < FONT_TEST_GLYPHS_PER_PAGE; ++offset) {
        const unsigned glyph = offset;
        const unsigned column = offset % FONT_TEST_COLUMNS;
        const unsigned row = offset / FONT_TEST_COLUMNS;
        const int x = (int)FONT_TEST_GRID_LEFT +
            (int)(column * PET2001_FONT_GLYPH_WIDTH);
        const int y = (int)FONT_TEST_GRID_TOP +
            (int)(row * PET2001_FONT_GLYPH_HEIGHT);
        drawPet2001Glyph(frame, x, y, (uint8_t)glyph, reverse,
                          COLOR_LIGHTGRAY, COLOR_BLACK, 1);
    }

    snprintf(heading, sizeof(heading), "%u/%u  A/K NEXT", page + 1U, FONT_TEST_PAGE_COUNT);
    drawPet2001TextCentredTransparent(frame, LCD_WIDTH / 2, 141, heading, COLOR_CYAN, 1);
    drawPet2001TextCentredTransparent(frame, LCD_WIDTH / 2, 157, "BOOT BACK",
                                       COLOR_LIGHTGRAY, 1);
}