new version
[Chiptunes-pms150c.git] / bsv.c
1 typedef unsigned char u8;
2
3 u8 i0, i1, i2; //MEM
4 u8 acc; //ACC
5
6 u8 notes[] = {
7 0x84, 0x9d, 0xb0, 0x69, 0x9d, 0x84, 0x69, 0x58,
8 0x75, 0x8c, 0xb0, 0x69, 0x8c, 0x75, 0x69, 0x58
9 };
10
11 void g(u8 t){
12 u8 notes_ix = t & 0x7;
13 if(3&i2)
14 notes_ix += 8;
15 u8 result = ((i1<<8|i0)*notes[notes_ix])>>8; // keep hi byte
16 acc = result;
17 }
18 void main(void){
19 i0 = i1 = i2 = 0;
20 // clear i0
21 // clear i1
22 // clear i2
23 for(;;) {
24 u8 sample;
25 u8 n = i2<<2 | i1>>6; //MEM
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
35
36 g(n);
37 //^TODO
38 acc >>= 4;
39 // swap acc
40 acc &= 1;
41 // and acc, 0x1
42 sample = acc;
43 // mov sample, acc
44
45 { u8 tmp;
46 tmp = i2<<3 | i1>>5;
47 tmp ^= n;
48 g(tmp);
49 //^TODO
50 } //tmp
51 acc >>= 1;
52 // sr acc
53 acc &= i2;
54 // and acc, i2
55 acc >>= 1;
56 // sr acc
57 acc &= 3;
58 // and acc, 3
59 sample += acc;
60 // add sample, acc
61
62 { u8 tmp2;
63 tmp2 = (i2<<5|i1>>3)%3;
64 tmp2 += n;
65 g(tmp2);
66 //^TODO
67 } //tmp2
68 acc >>= 2;
69 // sr acc
70 // sr acc
71 { u8 tmp1 = i2/6;
72 acc &= tmp1;
73 //^TODO
74 } //tmp1
75 acc &= 3;
76 // and acc, 3
77 sample += acc;
78 // add sample, acc
79
80 { u8 tmp2 = n;
81 { u8 tmp3 = (i2<<6|i1>>2)%3;
82 tmp2 -= tmp3;
83 } // tmp3
84 tmp2 += 8;
85 g(tmp2);
86 } //tmp2
87 acc >>= 1;
88 { u8 tmp1 = i2/10;
89 acc &= tmp1;
90 } //tmp1
91 acc &= 3;
92 sample += acc;
93
94 putchar(sample<<4);
95
96 i0++;
97 i1 += !i0;
98 i2 += !i1 && !i0;
99 }
100 }
Imprint / Impressum