-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfade.c
108 lines (97 loc) · 2.33 KB
/
fade.c
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
100
101
102
103
104
105
106
#include <gb/gb.h>
// #include "songPlayer.h"
UINT8 isFadedOut;
// UINT8 shouldStartMusic;
UINT8 getIsFadedOut()
{
return isFadedOut;
}
// UINT8 getShouldStartMusic()
// {
// if (shouldStartMusic != 1)
// {
// shouldStartMusic = 1;
// return 0;
// }
// else
// return 1;
// }
// void setShouldStartMusic(UINT8 val)
// {
// shouldStartMusic = val;
// }
void performantdelay(UINT8 numloops)
{
UINT8 j;
for (j = 0U; j != numloops; j++)
{
wait_vbl_done();
}
}
void fadein()
{
UINT8 i;
for (i = 0U; i != 3U; i++)
{
switch(i)
{
case 0U:
// OBP0_REG = 0x40; // Sprites
OBP0_REG = 0x40; // Dark grey as transparent
BGP_REG = 0x40; // Bkg
break;
case 1U:
// OBP0_REG = 0x90;
OBP0_REG = 0x81; // Dark grey as transparent
BGP_REG = 0x90;
break;
case 2U:
// OBP0_REG = 0xE4; // White as transparent
// OBP0_REG = 0xE1; // Light grey as transparent
OBP0_REG = 0xD2; // Dark grey as transparent 11010010
BGP_REG = 0xE4;
break;
}
performantdelay(1U);
}
isFadedOut = 0U;
// pauseSong(0U);
}
void fadeout()
{
UINT8 i;
// pauseSong(1U);
for (i = 0U; i != 4U; i++)
{
switch(i)
{
case 0U:
// OBP0_REG = 0xE4;
OBP0_REG = 0xD2; // Dark grey as transparent 11010010
BGP_REG = 0xE4;
break;
case 1U:
// OBP0_REG = 0x90;
OBP0_REG = 0x81; // Dark grey as transparent
BGP_REG = 0x90;
break;
case 2U:
// OBP0_REG = 0x40;
OBP0_REG = 0x40; // Dark grey as transparent
BGP_REG = 0x40;
break;
case 3U:
OBP0_REG = 0x00;
BGP_REG = 0x00;
break;
}
performantdelay(1U);
}
// TODO: change the 20 if more sprites get added
// I'm sure there's a better way to remove sprites
for (i = 0U; i != 20U; i++)
{
move_sprite(i, 0U, 0U);
}
isFadedOut = 1U;
}