Credits
Source: src/credits.c · 64 lines · 4 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
startCredits() · source line 16
void startCredits(void)
- Execute
selected_credit = 0; - Execute
credit_message[0] = '\0'; - Execute
running = true;
Read original function source
void startCredits(void)
{
selected_credit = 0;
credit_message[0] = '\0';
running = true;
}stopCredits() · source line 23
void stopCredits(void)
- Execute
running = false;
Read original function source
void stopCredits(void) { running = false; }creditsAction() · source line 25
bool creditsAction(bool next, bool select)
Calls into this documentation:
- Decision
!runningTrue- Exit this function
return false;
FalseContinue after this decision.
- Decision
nextTrue- Execute
selected_credit = (selected_credit + 1U) % CREDIT_OPTION_COUNT; - Execute
credit_message[0] = '\0'; - Exit this function
return false;
FalseContinue after this decision.
- Decision
!selectTrue- Exit this function
return false;
FalseContinue after this decision.
- Decision
selected_credit == CREDIT_BACKTrue- Execute
stopCredits(); - Exit this function
return true;
FalseContinue after this decision.
- Execute
const uint32_t amount = credit_amounts[selected_credit]; - Decision
addGold(amount)True- Execute
snprintf(credit_message, sizeof(credit_message), "ADDED %u", (unsigned)amount);
False- Execute
snprintf(credit_message, sizeof(credit_message), "ADD FAILED");
- Exit this function
return false;
Read original function source
bool creditsAction(bool next, bool select)
{
if (!running) return false;
if (next) {
selected_credit = (selected_credit + 1U) % CREDIT_OPTION_COUNT;
credit_message[0] = '\0';
return false;
}
if (!select) return false;
if (selected_credit == CREDIT_BACK) {
stopCredits();
return true;
}
const uint32_t amount = credit_amounts[selected_credit];
if (addGold(amount)) snprintf(credit_message, sizeof(credit_message), "ADDED %u", (unsigned)amount);
else snprintf(credit_message, sizeof(credit_message), "ADD FAILED");
return false;
}drawCredits() · source line 44
void drawCredits(uint16_t *frame)
Calls into this documentation:
- Decision
!runningTrue- Exit this function
return;
FalseContinue after this decision.
- Execute
char text[32]; - Execute
clear(frame, COLOR_BLACK); - Execute
draw_text_centred(frame, 160, 7, "CREDITS", 3, COLOR_CYAN); - Execute
draw_text(frame, 25, 47, "BALANCE", 2, COLOR_WHITE); - Execute
snprintf(text, sizeof(text), "%u", (unsigned)getGold()); - Execute
draw_text_centred(frame, 245, 47, text, 2, COLOR_GOLD); - Execute
draw_text(frame, 25, 86, "ADD", 2, COLOR_WHITE); - Decision
selected_credit == CREDIT_BACKTrue- Execute
draw_text_centred(frame, 205, 83, "BACK", 3, COLOR_YELLOW);
False- Execute
snprintf(text, sizeof(text), "+%u", (unsigned)credit_amounts[selected_credit]); - Execute
draw_text_centred(frame, 205, 83, text, 3, COLOR_YELLOW);
- Execute
draw_text_centred(frame, 160, 122, credit_message, 2, credit_message[0] == '\0' ? COLOR_CYAN : COLOR_LIGHTCYAN); - Execute
draw_text_centred(frame, 160, 154, "A/K NEXT F SELECT BOOT BACK", 1, COLOR_LIGHTGRAY);
Read original function source
void drawCredits(uint16_t *frame)
{
if (!running) return;
char text[32];
clear(frame, COLOR_BLACK);
draw_text_centred(frame, 160, 7, "CREDITS", 3, COLOR_CYAN);
draw_text(frame, 25, 47, "BALANCE", 2, COLOR_WHITE);
snprintf(text, sizeof(text), "%u", (unsigned)getGold());
draw_text_centred(frame, 245, 47, text, 2, COLOR_GOLD);
draw_text(frame, 25, 86, "ADD", 2, COLOR_WHITE);
if (selected_credit == CREDIT_BACK) {
draw_text_centred(frame, 205, 83, "BACK", 3, COLOR_YELLOW);
} else {
snprintf(text, sizeof(text), "+%u", (unsigned)credit_amounts[selected_credit]);
draw_text_centred(frame, 205, 83, text, 3, COLOR_YELLOW);
}
draw_text_centred(frame, 160, 122, credit_message, 2,
credit_message[0] == '\0' ? COLOR_CYAN : COLOR_LIGHTCYAN);
draw_text_centred(frame, 160, 154, "A/K NEXT F SELECT 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 "credits.h"
#include "game_graphics.h"
#include "PET2001_font.h"
#include "gold.h"
#include <stdio.h>
static const uint32_t credit_amounts[] = {10U, 50U, 100U, 500U, 1000U};
#define CREDIT_AMOUNT_COUNT (sizeof(credit_amounts) / sizeof(credit_amounts[0]))
#define CREDIT_BACK CREDIT_AMOUNT_COUNT
#define CREDIT_OPTION_COUNT (CREDIT_AMOUNT_COUNT + 1U)
static uint8_t selected_credit;
static bool running;
static char credit_message[24];
void startCredits(void)
{
selected_credit = 0;
credit_message[0] = '\0';
running = true;
}
void stopCredits(void) { running = false; }
bool creditsAction(bool next, bool select)
{
if (!running) return false;
if (next) {
selected_credit = (selected_credit + 1U) % CREDIT_OPTION_COUNT;
credit_message[0] = '\0';
return false;
}
if (!select) return false;
if (selected_credit == CREDIT_BACK) {
stopCredits();
return true;
}
const uint32_t amount = credit_amounts[selected_credit];
if (addGold(amount)) snprintf(credit_message, sizeof(credit_message), "ADDED %u", (unsigned)amount);
else snprintf(credit_message, sizeof(credit_message), "ADD FAILED");
return false;
}
void drawCredits(uint16_t *frame)
{
if (!running) return;
char text[32];
clear(frame, COLOR_BLACK);
drawPet2001TextCentredTransparent(frame, 160, 7, "CREDITS", COLOR_CYAN, 3);
drawPet2001TextTransparent(frame, 25, 47, "BALANCE", COLOR_WHITE, 2);
snprintf(text, sizeof(text), "%u", (unsigned)getGold());
drawPet2001TextCentredTransparent(frame, 245, 47, text, COLOR_GOLD, 2);
drawPet2001TextTransparent(frame, 25, 86, "ADD", COLOR_WHITE, 2);
if (selected_credit == CREDIT_BACK) {
drawPet2001TextCentredTransparent(frame, 205, 83, "BACK", COLOR_YELLOW, 3);
} else {
snprintf(text, sizeof(text), "+%u", (unsigned)credit_amounts[selected_credit]);
drawPet2001TextCentredTransparent(frame, 205, 83, text, COLOR_YELLOW, 3);
}
drawPet2001TextCentredTransparent(frame, 160, 122, credit_message,
credit_message[0] == '\0' ? COLOR_CYAN : COLOR_LIGHTCYAN, 2);
drawPet2001TextCentredTransparent(frame, 160, 154, "A/K NEXT F SELECT BOOT BACK", COLOR_LIGHTGRAY, 1);
}