-
Notifications
You must be signed in to change notification settings - Fork 2
/
Sound.ZC
executable file
·102 lines (91 loc) · 1.79 KB
/
Sound.ZC
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
U0 GBSoundTask(U8 *regs)
{
I64 frmCtr=0;
I64 restCtrA=0;
I64 restCtrB=0;
I64 restA=0;
I64 restB=0;
I64 div;
I64 freq;
I64 x;
I64 prevA=0;
I64 prevB=0;
while (TRUE)
{
if(memory[0xFEED]==0)
{
restA=1;
if (memory[0xFF12]>0b10000)
{
x = memory[0xFF13];
x += ((memory[0xFF14] & 0b00000111)<<8);
if (x!=prevA)
{
freq=131072/(2048-x);
div=1193180/freq;
// I wanted to use Sound(Freq2Ona(freq)); here
// instead of I/O port writes, but the
// conversion isn't right...?
OutU8(0x43, 0xB6);
OutU8(0x42, div);
OutU8(0x42, div>>8);
OutU8(0x61,3|InU8(0x61));
prevA=x;
restA=0;
restCtrA=0;
};
} else {
};
if (restA==1)
{
restCtrA++;
if (restCtrA>30000)
{
SoundReset;
SoundReset;
restCtrA=0;
//prevB=0;
};
};
};
if(memory[0xFEED]==1)
{
restB=1;
if (memory[0xFF17]>0b10000)
{
x = memory[0xFF18];
x += ((memory[0xFF19] & 0b00000111)<<8);
if (x!=prevB)
{
freq=131072/(2048-x);
div=1193180/freq;
OutU8(0x43, 0xB6);
OutU8(0x42, div);
OutU8(0x42, div>>8);
OutU8(0x61,3|InU8(0x61));
prevB=x;
restB=0;
restCtrB=0;
};
} else {
};
if (restB==1)
{
restCtrB++;
if (restCtrB>30000)
{
SoundReset;
SoundReset;
restCtrB=0;
//prevA=0;
};
};
};
if(memory[0xFEED]==128)
{
SoundReset;
};
frmCtr=0;
while(frmCtr<30000){frmCtr++;};
};
}