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