new version
[Chiptunes-pms150c.git] / bsv.c
1 typedef unsigned char u8;
2
3 u8 i0, i1, i2;
4
5 u8 notes[] = {
6 0x84, 0x9d, 0xb0, 0x69, 0x9d, 0x84, 0x69, 0x58,
7 0x75, 0x8c, 0xb0, 0x69, 0x8c, 0x75, 0x69, 0x58
8 };
9
10 u8 g(u8 x, u8 t, u8 o){
11 u8 notes_ix = t & 0x7;
12 if(3&i2)
13 notes_ix += 8;
14 u8 result = ((i1<<8|i0)*notes[notes_ix])>>o;
15 result &= x;
16 result &= 3;
17 return result;
18 }
19 void main(void){
20 i0 = i1 = i2 = 0;
21 for(;;) {
22 u8 sample;
23 u8 n = i2<<2 | i1>>6;
24 u8 s = i2>>1;
25
26 sample = g(1,n,12);
27
28 { u8 tmp;
29 tmp = i2<<3 | i1>>5;
30 tmp ^= n;
31 sample += g(s,tmp,10);
32 } //tmp
33
34 { u8 tmp1 = s/3;
35 u8 tmp2;
36 tmp2 = (i2<<5|i1>>3)%3;
37 tmp2 += n;
38 sample += g(tmp1,tmp2,10);
39 } //tmp1, tmp2
40
41 { u8 tmp1 = s/5;
42 u8 tmp2 = n;
43 { u8 tmp3 = (i2<<6|i1>>2)%3;
44 tmp2 -= tmp3;
45 } // tmp3
46 tmp2 += 8;
47 sample += g(tmp1,tmp2,9);
48 } //tmp1, tmp2
49
50 putchar(sample<<4);
51
52 i0++;
53 i1 += !i0;
54 i2 += !i1 && !i0;
55 }
56 }
Imprint / Impressum