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)
  1. Executeselected_credit = 0;
  2. Executecredit_message[0] = '\0';
  3. Executerunning = true;
Read original function source
void startCredits(void)
{
    selected_credit = 0;
    credit_message[0] = '\0';
    running = true;
}
stopCredits() · source line 23
void stopCredits(void)
  1. Executerunning = false;
Read original function source
void stopCredits(void) { running = false; }
creditsAction() · source line 25
bool creditsAction(bool next, bool select)

Calls into this documentation:

  1. Decision!running
    True
    1. Exit this functionreturn false;
    False

    Continue after this decision.

  2. Decisionnext
    True
      1. Executeselected_credit = (selected_credit + 1U) % CREDIT_OPTION_COUNT;
      2. Executecredit_message[0] = '\0';
      3. Exit this functionreturn false;
    False

    Continue after this decision.

  3. Decision!select
    True
    1. Exit this functionreturn false;
    False

    Continue after this decision.

  4. Decisionselected_credit == CREDIT_BACK
    True
      1. ExecutestopCredits();
      2. Exit this functionreturn true;
    False

    Continue after this decision.

  5. Executeconst uint32_t amount = credit_amounts[selected_credit];
  6. DecisionaddGold(amount)
    True
    1. Executesnprintf(credit_message, sizeof(credit_message), "ADDED %u", (unsigned)amount);
    False
    1. Executesnprintf(credit_message, sizeof(credit_message), "ADD FAILED");
  7. Exit this functionreturn 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:

  1. Decision!running
    True
    1. Exit this functionreturn;
    False

    Continue after this decision.

  2. Executechar text[32];
  3. Executeclear(frame, COLOR_BLACK);
  4. Executedraw_text_centred(frame, 160, 7, "CREDITS", 3, COLOR_CYAN);
  5. Executedraw_text(frame, 25, 47, "BALANCE", 2, COLOR_WHITE);
  6. Executesnprintf(text, sizeof(text), "%u", (unsigned)getGold());
  7. Executedraw_text_centred(frame, 245, 47, text, 2, COLOR_GOLD);
  8. Executedraw_text(frame, 25, 86, "ADD", 2, COLOR_WHITE);
  9. Decisionselected_credit == CREDIT_BACK
    True
      1. Executedraw_text_centred(frame, 205, 83, "BACK", 3, COLOR_YELLOW);
    False
      1. Executesnprintf(text, sizeof(text), "+%u", (unsigned)credit_amounts[selected_credit]);
      2. Executedraw_text_centred(frame, 205, 83, text, 3, COLOR_YELLOW);
  10. Executedraw_text_centred(frame, 160, 122, credit_message, 2, credit_message[0] == '\0' ? COLOR_CYAN : COLOR_LIGHTCYAN);
  11. Executedraw_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);
}