Font Test
Source: src/font_test.c · 68 lines · 4 functions.
Screen / module overview
- Enter Font Test
Set running and select the normal page.
- A / K next page
Alternate between normal and reverse PET glyph pages.
- Draw the page
Clear black. Draw all 256 glyphs in a 32-column grid with page heading and controls.
- 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)
- Execute
running = true; - Execute
page = 0U;
Read original function source
void startFontTest(void)
{
running = true;
page = 0U;
}stopFontTest() · source line 27
void stopFontTest(void)
- Execute
running = false;
Read original function source
void stopFontTest(void)
{
running = false;
}fontTestAction() · source line 32
void fontTestAction(bool next_page)
- Decision
!running || !next_pageTrue- Exit this function
return;
FalseContinue after this decision.
- Execute
page = (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:
- Decision
!running || frame == NULLTrue- Exit this function
return;
FalseContinue after this decision.
- Execute
clear(frame, COLOR_BLACK); - Execute
const bool reverse = page != 0U; - Execute
char heading[32]; - Execute
snprintf(heading, sizeof(heading), "PET 00-FF %s", reverse ? "REVERSE" : "NORMAL"); - Execute
draw_text_centred(frame, LCD_WIDTH / 2, 5, heading, 2, COLOR_CYAN); - Execute
draw_text_centred(frame, LCD_WIDTH / 2, 27, "32 X 8 8X8 GLYPHS", 1, COLOR_LIGHTGRAY); - FOR loop
unsigned offset = 0U; offset < FONT_TEST_GLYPHS_PER_PAGE; ++offsetRepeat body while the loop condition permits; then continue below.
- Execute
const unsigned glyph = offset; - Execute
const unsigned column = offset % FONT_TEST_COLUMNS; - Execute
const unsigned row = offset / FONT_TEST_COLUMNS; - Execute
const int x = (int)FONT_TEST_GRID_LEFT + (int)(column * PET2001_FONT_GLYPH_WIDTH); - Execute
const int y = (int)FONT_TEST_GRID_TOP + (int)(row * PET2001_FONT_GLYPH_HEIGHT); - Execute
drawPet2001Glyph(frame, x, y, (uint8_t)glyph, reverse, COLOR_LIGHTGRAY, COLOR_BLACK, 1);
- Execute
snprintf(heading, sizeof(heading), "%u/%u A/K NEXT", page + 1U, FONT_TEST_PAGE_COUNT); - Execute
draw_text_centred(frame, LCD_WIDTH / 2, 141, heading, 1, COLOR_CYAN); - Execute
draw_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);
}