new version
[Chiptunes-pms150c.git] / bsv.c
CommitLineData
b3a565e1
TG
1typedef unsigned char u8;
2
268e276e
TG
3u8 i0, i1, i2; //MEM
4u8 acc; //ACC
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
268e276e 11void g(u8 t){
ac66812d
TG
12 u8 notes_ix = t & 0x7;
13 if(3&i2)
14 notes_ix += 8;
fb819dd9 15 u8 result = ((i1<<8|i0)*notes[notes_ix])>>8; // keep hi byte
268e276e 16 acc = result;
c395d5c8 17}
f3768c26 18void main(void){
63fc42a5 19 i0 = i1 = i2 = 0;
f3768c26 20 for(;;) {
fef0e35b 21 u8 sample;
ac66812d 22 u8 n = i2<<2 | i1>>6;
63fc42a5 23 u8 s = i2>>1;
bd4f3b3e 24
268e276e
TG
25 g(n);
26 acc >>= 4;
d76a3c5d 27 acc &= 1;
268e276e 28 sample = acc;
bd4f3b3e
TG
29
30 { u8 tmp;
31 tmp = i2<<3 | i1>>5;
32 tmp ^= n;
268e276e
TG
33 g(tmp);
34 acc >>= 2;
d76a3c5d
TG
35 acc &= s;
36 acc &= 3;
268e276e 37 sample += acc;
f3768c26 38 } //tmp
bd4f3b3e 39
f3768c26 40 { u8 tmp1 = s/3;
bd4f3b3e 41 u8 tmp2;
63fc42a5 42 tmp2 = (i2<<5|i1>>3)%3;
bd4f3b3e 43 tmp2 += n;
268e276e
TG
44 g(tmp2);
45 acc >>= 2;
d76a3c5d
TG
46 acc &= tmp1;
47 acc &= 3;
268e276e 48 sample += acc;
f3768c26 49 } //tmp1, tmp2
bd4f3b3e 50
f3768c26 51 { u8 tmp1 = s/5;
bd4f3b3e 52 u8 tmp2 = n;
63fc42a5 53 { u8 tmp3 = (i2<<6|i1>>2)%3;
bd4f3b3e
TG
54 tmp2 -= tmp3;
55 } // tmp3
56 tmp2 += 8;
268e276e
TG
57 g(tmp2);
58 acc >>= 1;
d76a3c5d
TG
59 acc &= tmp1;
60 acc &= 3;
268e276e 61 sample += acc;
f3768c26 62 } //tmp1, tmp2
bd4f3b3e 63
8a26e976 64 putchar(sample<<4);
ac66812d 65
ac66812d
TG
66 i0++;
67 i1 += !i0;
68 i2 += !i1 && !i0;
fef0e35b 69 }
c395d5c8 70}
Imprint / Impressum