-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflash.cpp
99 lines (90 loc) · 1.39 KB
/
flash.cpp
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include "flash.h"
EXPORT i32 FadeCountdown;
EXPORT i32 FlashCountdown;
EXPORT i32 Fading;
EXPORT u8 CurrentImportance;
EXPORT i32 FlashSort;
EXPORT u32 CurrentR;
EXPORT u32 CurrentG;
EXPORT u32 CurrentB;
EXPORT u32 dR;
EXPORT u32 dG;
EXPORT u32 dB;
// @Ok
// @Matching
i32 Flash_FadeFinished(void)
{
return FadeCountdown == 0;
}
// @MEDIUMTODO
void Flash_Display(void)
{
printf("Flash_Display(void)");
}
// @Ok
// @Matching
void Flash_Reset(void)
{
FlashCountdown = 0;
FadeCountdown = 0;
Fading = 0;
CurrentImportance = 0;
}
// @Ok
void Flash_Screen(
u8 StartR,
u8 StartG,
u8 StartB,
i32 Frames,
u8 Importance,
i32 Sort)
{
if (Importance >= CurrentImportance && Frames)
{
CurrentR = StartR << 16;
CurrentG = StartG << 16;
CurrentB = StartB << 16;
FlashCountdown = Frames;
CurrentImportance = Importance;
dR = (StartR << 16) / Frames;
dG = (StartG << 16) / Frames;
dB = (StartB << 16) / Frames;
FlashSort = Sort;
}
}
// @Ok
// @Matching
void Flash_Update(void)
{
if (Fading)
{
if (FadeCountdown)
{
if (--FadeCountdown == 0)
{
CurrentB = 0xFF0000;
CurrentG = 0xFF0000;
CurrentR = 0xFF0000;
}
else
{
CurrentR += dR;
CurrentG += dR;
CurrentB += dR;
}
}
}
else if (FlashCountdown)
{
if (--FlashCountdown == 0)
{
CurrentImportance = 0;
}
else
{
CurrentR -= dR;
CurrentG -= dG;
CurrentB -= dB;
}
}
}