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;
f345ce49
TG
20 // clear i0
21 // clear i1
22 // clear i2
f3768c26 23 for(;;) {
fef0e35b 24 u8 sample;
fd9dc6aa 25 u8 n = i2<<2 | i1>>6; //MEM
f345ce49
TG
26 // mov n, i2
27 // sl n
28 // sl n
29 // mov acc, i1
30 // swap acc
31 // and acc, 0xf
32 // sr acc
33 // sr acc
34 // or n, acc
bd4f3b3e 35
268e276e 36 g(n);
f345ce49 37 //^TODO
268e276e 38 acc >>= 4;
f345ce49 39 // swap acc
d76a3c5d 40 acc &= 1;
f345ce49 41 // and acc, 0x1
268e276e 42 sample = acc;
f345ce49 43 // mov sample, acc
bd4f3b3e
TG
44
45 { u8 tmp;
46 tmp = i2<<3 | i1>>5;
47 tmp ^= n;
268e276e 48 g(tmp);
f345ce49
TG
49 //^TODO
50 } //tmp
fd9dc6aa 51 acc >>= 1;
f345ce49 52 // sr acc
fd9dc6aa
TG
53 acc &= i2;
54 // and acc, i2
55 acc >>= 1;
f345ce49 56 // sr acc
d76a3c5d 57 acc &= 3;
f345ce49 58 // and acc, 3
268e276e 59 sample += acc;
f345ce49 60 // add sample, acc
bd4f3b3e 61
f345ce49 62 { u8 tmp2;
63fc42a5 63 tmp2 = (i2<<5|i1>>3)%3;
bd4f3b3e 64 tmp2 += n;
268e276e 65 g(tmp2);
f345ce49
TG
66 //^TODO
67 } //tmp2
268e276e 68 acc >>= 2;
f345ce49
TG
69 // sr acc
70 // sr acc
fd9dc6aa 71 { u8 tmp1 = i2/6;
d76a3c5d 72 acc &= tmp1;
f345ce49
TG
73 //^TODO
74 } //tmp1
d76a3c5d 75 acc &= 3;
f345ce49 76 // and acc, 3
268e276e 77 sample += acc;
f345ce49 78 // add sample, acc
bd4f3b3e 79
f345ce49 80 { u8 tmp2 = n;
63fc42a5 81 { u8 tmp3 = (i2<<6|i1>>2)%3;
bd4f3b3e
TG
82 tmp2 -= tmp3;
83 } // tmp3
84 tmp2 += 8;
268e276e 85 g(tmp2);
f345ce49 86 } //tmp2
268e276e 87 acc >>= 1;
fd9dc6aa 88 { u8 tmp1 = i2/10;
d76a3c5d 89 acc &= tmp1;
f345ce49 90 } //tmp1
d76a3c5d 91 acc &= 3;
268e276e 92 sample += acc;
bd4f3b3e 93
8a26e976 94 putchar(sample<<4);
ac66812d 95
ac66812d
TG
96 i0++;
97 i1 += !i0;
98 i2 += !i1 && !i0;
fef0e35b 99 }
c395d5c8 100}
Imprint / Impressum