]> git.gir.st - Chiptunes-pms150c.git/blob - bsv.c
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])>>8; // keep hi byte
15 result >>= o;
16 result &= x;
17 result &= 3;
18 return result;
19 }
20 void main(void){
21 i0 = i1 = i2 = 0;
22 for(;;) {
23 u8 sample;
24 u8 n = i2<<2 | i1>>6;
25 u8 s = i2>>1;
26
27 sample = g(1,n,4);
28
29 { u8 tmp;
30 tmp = i2<<3 | i1>>5;
31 tmp ^= n;
32 sample += g(s,tmp,2);
33 } //tmp
34
35 { u8 tmp1 = s/3;
36 u8 tmp2;
37 tmp2 = (i2<<5|i1>>3)%3;
38 tmp2 += n;
39 sample += g(tmp1,tmp2,2);
40 } //tmp1, tmp2
41
42 { u8 tmp1 = s/5;
43 u8 tmp2 = n;
44 { u8 tmp3 = (i2<<6|i1>>2)%3;
45 tmp2 -= tmp3;
46 } // tmp3
47 tmp2 += 8;
48 sample += g(tmp1,tmp2,1);
49 } //tmp1, tmp2
50
51 putchar(sample<<4);
52
53 i0++;
54 i1 += !i0;
55 i2 += !i1 && !i0;
56 }
57 }
Imprint / Impressum