-
Notifications
You must be signed in to change notification settings - Fork 0
/
sound.c
128 lines (107 loc) · 2.23 KB
/
sound.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// Plays the pause sound.
void pauseSound()
{
const int length = 50;
NR10_REG = 0x00;
NR11_REG = 0x80;
// C
NR12_REG = 0x43;
NR13_REG = 0x06;
NR14_REG = 0x87;
delay(length);
// E
NR12_REG = 0x43;
NR13_REG = 0x39;
NR14_REG = 0x87;
delay(length);
// G
NR12_REG = 0x43;
NR13_REG = 0x59;
NR14_REG = 0x87;
delay(length);
// High C
NR12_REG = 0x43;
NR13_REG = 0x82;
NR14_REG = 0x87;
// delay(length);
}
void unpauseSound()
{
const int length = 50;
// High C
NR12_REG = 0x43;
NR13_REG = 0x82;
NR14_REG = 0x87;
delay(length);
// G
NR12_REG = 0x43;
NR13_REG = 0x59;
NR14_REG = 0x87;
delay(length);
// E
NR12_REG = 0x43;
NR13_REG = 0x39;
NR14_REG = 0x87;
delay(length);
// C
NR12_REG = 0x43;
NR13_REG = 0x06;
NR14_REG = 0x87;
// delay(length);
}
void threeTwoOne()
{
// Lower C sound
NR10_REG = 0x00;
NR11_REG = 0X81;
NR12_REG = 0X43;
NR13_REG = 0X0D;
NR14_REG = 0X86;
}
void goSound()
{
// Higher C sound
NR10_REG = 0x00;
NR11_REG = 0X80;
NR12_REG = 0X40; // Perma note
NR13_REG = 0X06;
NR14_REG = 0X87;
delay(500);
NR12_REG = 0X41; // Stop the perma note
}
void scrollSound()
{
NR21_REG = 0x80;
NR22_REG = 0x41;
NR23_REG = 0x0E;
NR24_REG = 0x86;
}
// 321 GO sound with tile animation
void countdown()
{
int offset = 189;
for (int i = 0; i < 3; i++)
{
// Show 321
windowmap[offset] = 0x31 + (i * 4);
windowmap[offset + 1] = 0x32 + (i * 4);
windowmap[offset + 20] = 0x33 + (i * 4);
windowmap[offset + 21] = 0x34 + (i * 4);
set_win_tiles(0, 0, 20, 18, windowmap);
threeTwoOne();
delay(1000);
}
// Show GO
windowmap[offset] = 0x3D;
windowmap[offset + 1] = 0x3E;
windowmap[offset + 20] = 0x3F;
windowmap[offset + 21] = 0x40;
set_win_tiles(0, 0, 20, 18, windowmap);
goSound();
// Hide the GO
windowmap[offset] = 0x00;
windowmap[offset + 1] = 0x00;
windowmap[offset + 20] = 0x00;
windowmap[offset + 21] = 0x00;
set_win_tiles(0, 0, 20, 18, windowmap);
}