Global Overlay
Source: src/global_overlay.c · 87 lines · 6 functions.
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
globalOverlayInitialize() · source line 23
bool globalOverlayInitialize(void)
- Decision
presentation_frame != NULLTrue- Exit this function
return true;
FalseContinue after this decision.
- Execute
presentation_frame = heap_caps_malloc((size_t)LCD_WIDTH * LCD_HEIGHT * sizeof(*presentation_frame), MALLOC_CAP_SPIRAM | MALLOC_CAP_DMA | MALLOC_CAP_8BIT); - Exit this function
return presentation_frame != NULL;
Read original function source
bool globalOverlayInitialize(void)
{
if (presentation_frame != NULL) return true;
presentation_frame = heap_caps_malloc((size_t)LCD_WIDTH * LCD_HEIGHT * sizeof(*presentation_frame),
MALLOC_CAP_SPIRAM | MALLOC_CAP_DMA | MALLOC_CAP_8BIT);
return presentation_frame != NULL;
}globalOverlayDeinitialize() · source line 31
void globalOverlayDeinitialize(void)
Calls into this documentation:
- Execute
heap_caps_free(presentation_frame); - Execute
presentation_frame = NULL; - Execute
globalOverlayClear();
Read original function source
void globalOverlayDeinitialize(void)
{
heap_caps_free(presentation_frame);
presentation_frame = NULL;
globalOverlayClear();
}globalOverlaySetItem() · source line 38
bool globalOverlaySetItem(size_t item_index, const char *text, int x, int y, int scale,
uint16_t colour)- Decision
item_index >= GLOBAL_OVERLAY_ITEM_COUNT || text == NULL || text[0] == '\0' || scale <= 0True- Exit this function
return false;
FalseContinue after this decision.
- Execute
global_overlay_item_t *const item = &overlay_items[item_index]; - Execute
const size_t text_length = strnlen(text, sizeof(item->text) - 1U); - Execute
memcpy(item->text, text, text_length); - Execute
item->text[text_length] = '\0'; - Execute
item->x = x; - Execute
item->y = y; - Execute
item->scale = scale; - Execute
item->colour = colour; - Execute
item->visible = true; - Exit this function
return true;
Read original function source
bool globalOverlaySetItem(size_t item_index, const char *text, int x, int y, int scale,
uint16_t colour)
{
if (item_index >= GLOBAL_OVERLAY_ITEM_COUNT || text == NULL || text[0] == '\0' || scale <= 0) {
return false;
}
global_overlay_item_t *const item = &overlay_items[item_index];
const size_t text_length = strnlen(text, sizeof(item->text) - 1U);
memcpy(item->text, text, text_length);
item->text[text_length] = '\0';
item->x = x;
item->y = y;
item->scale = scale;
item->colour = colour;
item->visible = true;
return true;
}globalOverlayClearItem() · source line 57
void globalOverlayClearItem(size_t item_index)
- Decision
item_index >= GLOBAL_OVERLAY_ITEM_COUNTTrue- Exit this function
return;
FalseContinue after this decision.
- Execute
overlay_items[item_index] = (global_overlay_item_t){0};
Read original function source
void globalOverlayClearItem(size_t item_index)
{
if (item_index >= GLOBAL_OVERLAY_ITEM_COUNT) return;
overlay_items[item_index] = (global_overlay_item_t){0};
}globalOverlayClear() · source line 63
void globalOverlayClear(void)
- Execute
memset(overlay_items, 0, sizeof(overlay_items));
Read original function source
void globalOverlayClear(void)
{
memset(overlay_items, 0, sizeof(overlay_items));
}globalOverlayCompose() · source line 68
const uint16_t *globalOverlayCompose(const uint16_t *scene_frame)
Calls into this documentation:
- Decision
scene_frame == NULL || presentation_frame == NULLTrue- Exit this function
return scene_frame;
FalseContinue after this decision.
- Execute
bool visible_item_found = false; - FOR loop
size_t item_index = 0U; item_index < GLOBAL_OVERLAY_ITEM_COUNT; ++item_indexRepeat body while the loop condition permits; then continue below.
- Decision
overlay_items[item_index].visibleTrue- Execute
visible_item_found = true;
FalseContinue after this decision.
- Decision
!visible_item_foundTrue- Exit this function
return scene_frame;
FalseContinue after this decision.
- Execute
memcpy(presentation_frame, scene_frame, (size_t)LCD_WIDTH * LCD_HEIGHT * sizeof(*presentation_frame)); - FOR loop
size_t item_index = 0U; item_index < GLOBAL_OVERLAY_ITEM_COUNT; ++item_indexRepeat body while the loop condition permits; then continue below.
- Execute
const global_overlay_item_t *const item = &overlay_items[item_index]; - Decision
item->visibleTrue- Execute
draw_text(presentation_frame, item->x, item->y, item->text, item->scale, item->colour);
FalseContinue after this decision.
- Exit this function
return presentation_frame;
Read original function source
const uint16_t *globalOverlayCompose(const uint16_t *scene_frame)
{
if (scene_frame == NULL || presentation_frame == NULL) return scene_frame;
bool visible_item_found = false;
for (size_t item_index = 0U; item_index < GLOBAL_OVERLAY_ITEM_COUNT; ++item_index) {
if (overlay_items[item_index].visible) visible_item_found = true;
}
if (!visible_item_found) return scene_frame;
memcpy(presentation_frame, scene_frame,
(size_t)LCD_WIDTH * LCD_HEIGHT * sizeof(*presentation_frame));
for (size_t item_index = 0U; item_index < GLOBAL_OVERLAY_ITEM_COUNT; ++item_index) {
const global_overlay_item_t *const item = &overlay_items[item_index];
if (item->visible) draw_text(presentation_frame, item->x, item->y, item->text,
item->scale, item->colour);
}
return presentation_frame;
}Complete original file, including constants and data
/* Coded By JD(2026) */
#error "Reference listing only — not provided as build-ready source."
#include "global_overlay.h"
#include "game_graphics.h"
#include "PET2001_font.h"
#include "esp_heap_caps.h"
#include <string.h>
#define GLOBAL_OVERLAY_TEXT_LENGTH 48U
typedef struct {
bool visible;
char text[GLOBAL_OVERLAY_TEXT_LENGTH];
int x;
int y;
int scale;
uint16_t colour;
} global_overlay_item_t;
static global_overlay_item_t overlay_items[GLOBAL_OVERLAY_ITEM_COUNT];
static uint16_t *presentation_frame;
bool globalOverlayInitialize(void)
{
if (presentation_frame != NULL) return true;
presentation_frame = heap_caps_malloc((size_t)LCD_WIDTH * LCD_HEIGHT * sizeof(*presentation_frame),
MALLOC_CAP_SPIRAM | MALLOC_CAP_DMA | MALLOC_CAP_8BIT);
return presentation_frame != NULL;
}
void globalOverlayDeinitialize(void)
{
heap_caps_free(presentation_frame);
presentation_frame = NULL;
globalOverlayClear();
}
bool globalOverlaySetItem(size_t item_index, const char *text, int x, int y, int scale,
uint16_t colour)
{
if (item_index >= GLOBAL_OVERLAY_ITEM_COUNT || text == NULL || text[0] == '\0' || scale <= 0) {
return false;
}
global_overlay_item_t *const item = &overlay_items[item_index];
const size_t text_length = strnlen(text, sizeof(item->text) - 1U);
memcpy(item->text, text, text_length);
item->text[text_length] = '\0';
item->x = x;
item->y = y;
item->scale = scale;
item->colour = colour;
item->visible = true;
return true;
}
void globalOverlayClearItem(size_t item_index)
{
if (item_index >= GLOBAL_OVERLAY_ITEM_COUNT) return;
overlay_items[item_index] = (global_overlay_item_t){0};
}
void globalOverlayClear(void)
{
memset(overlay_items, 0, sizeof(overlay_items));
}
const uint16_t *globalOverlayCompose(const uint16_t *scene_frame)
{
if (scene_frame == NULL || presentation_frame == NULL) return scene_frame;
bool visible_item_found = false;
for (size_t item_index = 0U; item_index < GLOBAL_OVERLAY_ITEM_COUNT; ++item_index) {
if (overlay_items[item_index].visible) visible_item_found = true;
}
if (!visible_item_found) return scene_frame;
memcpy(presentation_frame, scene_frame,
(size_t)LCD_WIDTH * LCD_HEIGHT * sizeof(*presentation_frame));
for (size_t item_index = 0U; item_index < GLOBAL_OVERLAY_ITEM_COUNT; ++item_index) {
const global_overlay_item_t *const item = &overlay_items[item_index];
if (item->visible) drawPet2001TextTransparent(presentation_frame, item->x, item->y,
item->text, item->colour, item->scale);
}
return presentation_frame;
}