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