-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboot.c
More file actions
58 lines (51 loc) · 1.82 KB
/
Copy pathboot.c
File metadata and controls
58 lines (51 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// boot.c — see boot.h for the module overview.
#include "boot.h"
#include "context.h"
#include "display.h"
#include "audio.h"
#include "system.h"
#include <stddef.h>
#define BOOT_DURATION_MS 5000u
static uint32_t s_enterMs;
static uint8_t s_animState;
void bootEnter(void) {
s_animState = 0;
displayFillScreen(COLOR_BLACK);
s_enterMs = systemGetTimeMs();
}
void bootUpdate(uint32_t nowMs, uint16_t deltaMs) {
(void)deltaMs;
if (nowMs < s_enterMs) nowMs = s_enterMs;
uint32_t elapsed = nowMs - s_enterMs;
if (elapsed >= BOOT_DURATION_MS) {
contextRequestScreen(SCREEN_MENU);
} else {
// Fix 2: Sequential checks so missed frames catch up instantly
if (elapsed >= 1500 && s_animState < 1) {
s_animState = 1;
audioPlayTone(523, 500); // C5 (A)
displayDrawTextScaled(37, 40, "A", COLOR_BLUE, COLOR_BLACK, 3);
}
if (elapsed >= 2000 && s_animState < 2) {
s_animState = 2;
audioPlayTone(659, 500); // E5 (V)
displayDrawTextScaled(55, 40, "V", COLOR_BLUE, COLOR_BLACK, 3);
}
if (elapsed >= 2500 && s_animState < 3) {
s_animState = 3;
audioPlayTone(784, 500); // G5 (R)
displayDrawTextScaled(73, 40, "R", COLOR_BLUE, COLOR_BLACK, 3);
}
if (elapsed >= 3000 && s_animState < 4) {
s_animState = 4;
static const Note melody[] = {
{1046, 150}, {1318, 150}, {1568, 150}, {2093, 400}
};
audioPlaySequence(melody, 4); // GAMEBOY Melody
displayDrawTextScaled(22, 80, "GAMEBOY", COLOR_BLUE, COLOR_BLACK, 2);
}
}
}
void bootDraw(void) {
// Drawing is done progressively in bootUpdate based on timing states.
}