-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbeep.c
120 lines (97 loc) · 1.69 KB
/
beep.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
/*
*
* beep - try to manipulate the 4 settings for volume in order to see
* which ones (or whether all) cause a "pop" style volume spike
*
*/
#include "huc.h"
#define STATUS_LINE 3
char glb_bal;
char chn_bal;
char ctrl;
#asm
_beepsetup:
lda #2
sta psg_ch
lda #$FF
sta psg_mainvol
lda #$1C ; 4KHz
sta psg_freqlo
stz psg_freqhi
lda #$0
sta psg_ctrl
lda #$1F
ldx #16
.loop:
sta psg_wavebuf
dex
bne .loop
lda #$0
ldx #16
.loop1:
sta psg_wavebuf
dex
bne .loop1
lda #$FF
sta psg_pan
lda #$9f
sta psg_ctrl
rts
_beepoff:
lda #$0
sta psg_ctrl
rts
_beepon:
lda #$9f
sta psg_ctrl
rts
#endasm
char a;
main()
{
set_color(0,0);
set_color(1,511);
beepsetup();
beepoff();
while (1) {
vsync(0);
a = joy(0);
if (a & JOY_DOWN) {
put_string("D", 1, STATUS_LINE);
ctrl = (ctrl & 0x80);
} else {
put_string(" ", 1, STATUS_LINE);
ctrl = (ctrl & 0x80) | 0x1f;
}
if (a & JOY_SEL) {
put_string("S", 2, STATUS_LINE);
ctrl = (ctrl & 0x1f);
} else {
put_string(" ", 2, STATUS_LINE);
ctrl = (ctrl & 0x1f) | 0x80;
}
if (a & JOY_II) {
put_string("2", 3, STATUS_LINE);
glb_bal = 0;
} else {
put_string(" ", 3, STATUS_LINE);
glb_bal = 255;
}
if (a & JOY_I) {
put_string("1", 4, STATUS_LINE);
chn_bal = 0;
} else {
put_string(" ", 4, STATUS_LINE);
chn_bal = 255;
}
#asm
lda _glb_bal
sta psg_mainvol
lda _chn_bal
sta psg_pan
lda _ctrl
sta psg_ctrl
#endasm
}
return;
}