Demo Selector
Source: src/demo_selector.c · 111 lines · 5 functions.
Screen captures
Views of this part running on the Mini Arcade.

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
demoSelectorTimeoutPresetMs() · source line 75
static uint32_t demoSelectorTimeoutPresetMs(uint8_t preset)
- Select a case
presetEnter matching case; follow source fall-through until a break, return or end.
- Case / label
case 1U: - Exit this function
return DEMO_TIMEOUT_PRESET_1_MS; - Case / label
case 2U: - Exit this function
return DEMO_TIMEOUT_PRESET_2_MS; - Case / label
case 3U: - Exit this function
return DEMO_TIMEOUT_PRESET_3_MS; - Case / label
default: - Exit this function
return DEMO_TIMEOUT_PRESET_2_MS;
Read original function source
static uint32_t demoSelectorTimeoutPresetMs(uint8_t preset)
{
switch (preset) {
case 1U: return DEMO_TIMEOUT_PRESET_1_MS;
case 2U: return DEMO_TIMEOUT_PRESET_2_MS;
case 3U: return DEMO_TIMEOUT_PRESET_3_MS;
default: return DEMO_TIMEOUT_PRESET_2_MS;
}
}demoSelectorStageCodeName() · source line 85
const char *demoSelectorStageCodeName(demo_stage_t stage)
- Exit this function
return (unsigned)stage < DEMO_STAGE_COUNT ? demo_stage_code_names[stage] : "DEMO_STAGE_UNKNOWN";
Read original function source
const char *demoSelectorStageCodeName(demo_stage_t stage)
{
return (unsigned)stage < DEMO_STAGE_COUNT ? demo_stage_code_names[stage] : "DEMO_STAGE_UNKNOWN";
}demoSelectorStageScreenshotLabel() · source line 90
const char *demoSelectorStageScreenshotLabel(demo_stage_t stage)
- Exit this function
return (unsigned)stage < DEMO_STAGE_COUNT ? demo_stage_screenshot_labels[stage] : "demo-unknown";
Read original function source
const char *demoSelectorStageScreenshotLabel(demo_stage_t stage)
{
return (unsigned)stage < DEMO_STAGE_COUNT ? demo_stage_screenshot_labels[stage] : "demo-unknown";
}demoSelectorStageInactivityTimeout() · source line 95
uint32_t demoSelectorStageInactivityTimeout(demo_stage_t stage)
Calls into this documentation:
- Exit this function
return (unsigned)stage < DEMO_STAGE_COUNT ? demoSelectorTimeoutPresetMs(demo_stage_timeout_presets[stage]) : DEMO_TIMEOUT_PRESET_2_MS;
Read original function source
uint32_t demoSelectorStageInactivityTimeout(demo_stage_t stage)
{
return (unsigned)stage < DEMO_STAGE_COUNT ?
demoSelectorTimeoutPresetMs(demo_stage_timeout_presets[stage]) : DEMO_TIMEOUT_PRESET_2_MS;
}demoSelectorNextAutomaticStage() · source line 101
demo_stage_t demoSelectorNextAutomaticStage(demo_stage_t current_stage)
- FOR loop
size_t index = 0U; index < DEMO_AUTOMATIC_STAGE_COUNT; ++indexRepeat body while the loop condition permits; then continue below.
- Decision
demo_automatic_stages[index] == current_stageTrue- Exit this function
return demo_automatic_stages[(index + 1U) % DEMO_AUTOMATIC_STAGE_COUNT];
FalseContinue after this decision.
- Exit this function
return DEMO_STAGE_KALEIDO;
Read original function source
demo_stage_t demoSelectorNextAutomaticStage(demo_stage_t current_stage)
{
for (size_t index = 0U; index < DEMO_AUTOMATIC_STAGE_COUNT; ++index) {
if (demo_automatic_stages[index] == current_stage) {
return demo_automatic_stages[(index + 1U) % DEMO_AUTOMATIC_STAGE_COUNT];
}
}
// A manually selected Walloons segment advances to the following automatic stage.
return DEMO_STAGE_KALEIDO;
}Complete original file, including constants and data
/* Coded By JD(2026) */
#error "Reference listing only — not provided as build-ready source."
#include "demo_selector.h"
#include <stddef.h>
// Shared Demo inactivity timeout presets. Tune a duration here once; each
// segment chooses its preset below. Keeping this data with the selector means
// later stage modules do not need to know how Demo rotation is timed.
#define DEMO_TIMEOUT_PRESET_1_MS 30000U
#define DEMO_TIMEOUT_PRESET_2_MS 60000U
#define DEMO_TIMEOUT_PRESET_3_MS 90000U
// Walloons remains fully implemented for the USER-button segment selector, but it
// is deliberately excluded from the normal automatic Demo rotation.
static const demo_stage_t demo_automatic_stages[] = {
DEMO_STAGE_ICON,
DEMO_STAGE_APPROACH,
DEMO_STAGE_AMIGA_BALL,
DEMO_STAGE_SCROLLER,
DEMO_STAGE_REVERSE_SCROLLER,
DEMO_STAGE_GEOMETRIC_SOLID,
DEMO_STAGE_KALEIDO,
DEMO_STAGE_SPARKLE,
DEMO_STAGE_SQUARES,
DEMO_STAGE_RASTER_BANDS,
DEMO_STAGE_SLIDESHOW_LENS,
DEMO_STAGE_PLASMA,
DEMO_STAGE_GAME_OF_LIFE,
DEMO_STAGE_LOWER_RASTER_SCROLLER,
DEMO_STAGE_BATTLE_ZONE_RASTER,
DEMO_STAGE_BEVEL_GEARS,
DEMO_STAGE_MOUSE_MAZE,
};
#define DEMO_AUTOMATIC_STAGE_COUNT \
(sizeof(demo_automatic_stages) / sizeof(demo_automatic_stages[0]))
static const char *const demo_stage_code_names[DEMO_STAGE_COUNT] = {
"DEMO_STAGE_ICON",
"DEMO_STAGE_APPROACH",
"DEMO_STAGE_AMIGA_BALL",
"DEMO_STAGE_SCROLLER",
"DEMO_STAGE_REVERSE_SCROLLER",
"DEMO_STAGE_GEOMETRIC_SOLID",
"DEMO_STAGE_WALLOONS",
"DEMO_STAGE_KALEIDO",
"DEMO_STAGE_SPARKLE",
"DEMO_STAGE_SQUARES",
"DEMO_STAGE_RASTER_BANDS",
"DEMO_STAGE_SLIDESHOW_LENS",
"DEMO_STAGE_PLASMA",
"DEMO_STAGE_GAME_OF_LIFE",
"DEMO_STAGE_LOWER_RASTER_SCROLLER",
"DEMO_STAGE_BATTLE_ZONE_RASTER",
"DEMO_STAGE_BEVEL_GEARS",
"DEMO_STAGE_MOUSE_MAZE",
};
static const char *const demo_stage_screenshot_labels[DEMO_STAGE_COUNT] = {
"demo-segment-01-icon", "demo-segment-02-approach",
"demo-segment-03-amiga-ball", "demo-segment-04-scroller",
"demo-segment-05-reverse-scroller", "demo-segment-06-geometric-solid",
"demo-segment-07-walloons", "demo-segment-08-kaleido",
"demo-segment-09-sparkle", "demo-segment-10-squares",
"demo-segment-11-raster-bands", "demo-segment-12-slideshow-lens",
"demo-segment-13-plasma", "demo-segment-14-game-of-life",
"demo-segment-15-lower-raster-scroller", "demo-segment-16-battle-zone-raster",
"demo-segment-17-bevel-gears", "demo-segment-18-mouse-maze",
};
// Per-segment timeout preset assignment, in Demo segment order 1 through 18.
// Change an entry to 1U, 2U, or 3U to select the corresponding shared preset above.
static const uint8_t demo_stage_timeout_presets[DEMO_STAGE_COUNT] = {
1U, 2U, 2U, 2U, 2U, 2U, 2U, 2U, 2U, 2U, 2U, 2U, 2U, 2U, 2U, 2U, 2U, 2U,
};
static uint32_t demoSelectorTimeoutPresetMs(uint8_t preset)
{
switch (preset) {
case 1U: return DEMO_TIMEOUT_PRESET_1_MS;
case 2U: return DEMO_TIMEOUT_PRESET_2_MS;
case 3U: return DEMO_TIMEOUT_PRESET_3_MS;
default: return DEMO_TIMEOUT_PRESET_2_MS;
}
}
const char *demoSelectorStageCodeName(demo_stage_t stage)
{
return (unsigned)stage < DEMO_STAGE_COUNT ? demo_stage_code_names[stage] : "DEMO_STAGE_UNKNOWN";
}
const char *demoSelectorStageScreenshotLabel(demo_stage_t stage)
{
return (unsigned)stage < DEMO_STAGE_COUNT ? demo_stage_screenshot_labels[stage] : "demo-unknown";
}
uint32_t demoSelectorStageInactivityTimeout(demo_stage_t stage)
{
return (unsigned)stage < DEMO_STAGE_COUNT ?
demoSelectorTimeoutPresetMs(demo_stage_timeout_presets[stage]) : DEMO_TIMEOUT_PRESET_2_MS;
}
demo_stage_t demoSelectorNextAutomaticStage(demo_stage_t current_stage)
{
for (size_t index = 0U; index < DEMO_AUTOMATIC_STAGE_COUNT; ++index) {
if (demo_automatic_stages[index] == current_stage) {
return demo_automatic_stages[(index + 1U) % DEMO_AUTOMATIC_STAGE_COUNT];
}
}
// A manually selected Walloons segment advances to the following automatic stage.
return DEMO_STAGE_KALEIDO;
}