]> git.gir.st - Chiptunes-pms150c.git/blob - bsv.c
672ecf5bbff1782c63b7b23c22dca7b9735e7b23
[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;
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 u8 s = i2>>1;
36 // mov s, i2
37 // sr s
38
39 g(n);
40 //^TODO
41 acc >>= 4;
42 // swap acc
43 acc &= 1;
44 // and acc, 0x1
45 sample = acc;
46 // mov sample, acc
47
48 { u8 tmp;
49 tmp = i2<<3 | i1>>5;
50 tmp ^= n;
51 g(tmp);
52 //^TODO
53 } //tmp
54 acc >>= 2;
55 // sr acc
56 // sr acc
57 acc &= s;
58 // and acc, s
59 acc &= 3;
60 // and acc, 3
61 sample += acc;
62 // add sample, acc
63
64 { u8 tmp2;
65 tmp2 = (i2<<5|i1>>3)%3;
66 tmp2 += n;
67 g(tmp2);
68 //^TODO
69 } //tmp2
70 acc >>= 2;
71 // sr acc
72 // sr acc
73 { u8 tmp1 = s/3;
74 acc &= tmp1;
75 //^TODO
76 } //tmp1
77 acc &= 3;
78 // and acc, 3
79 sample += acc;
80 // add sample, acc
81
82 { u8 tmp2 = n;
83 { u8 tmp3 = (i2<<6|i1>>2)%3;
84 tmp2 -= tmp3;
85 } // tmp3
86 tmp2 += 8;
87 g(tmp2);
88 } //tmp2
89 acc >>= 1;
90 { u8 tmp1 = s/5;
91 acc &= tmp1;
92 } //tmp1
93 acc &= 3;
94 sample += acc;
95
96 putchar(sample<<4);
97
98 i0++;
99 i1 += !i0;
100 i2 += !i1 && !i0;
101 }
102 }
Imprint / Impressum