new version
[Chiptunes-pms150c.git] / bsv.c
CommitLineData
5ebb16dc
TG
1#include <stdio.h>
2#include "fakeasm.h"
b3a565e1
TG
3typedef unsigned char u8;
4
268e276e 5u8 i0, i1, i2; //MEM
7e02078f 6u8 n; //MEM
5ebb16dc 7u8 sample; //MEM
268e276e 8u8 acc; //ACC
f3768c26 9
c1873bed
TG
10u8 notes[] = {
11 0x84, 0x9d, 0xb0, 0x69, 0x9d, 0x84, 0x69, 0x58,
12 0x75, 0x8c, 0xb0, 0x69, 0x8c, 0x75, 0x69, 0x58
13};
c320426f 14
268e276e 15void g(u8 t){
ac66812d
TG
16 u8 notes_ix = t & 0x7;
17 if(3&i2)
18 notes_ix += 8;
fb819dd9 19 u8 result = ((i1<<8|i0)*notes[notes_ix])>>8; // keep hi byte
268e276e 20 acc = result;
c395d5c8 21}
f3768c26 22void main(void){
5ebb16dc
TG
23 CLEAR (i0)
24 CLEAR (i1)
25 CLEAR (i2)
f3768c26 26 for(;;) {
5ebb16dc
TG
27 /*n = i2<<2 | i1>>6;*/
28 MOV (n, i2)
29 SL (n)
30 SL (n)
31 MOV (acc, i1)
32 SWAP (acc)
33 AND (acc, 0xf)
34 SR (acc)
35 SR (acc)
36 OR (n, acc)
bd4f3b3e 37
268e276e 38 g(n);
f345ce49 39 //^TODO
5ebb16dc
TG
40 SWAP (acc)
41 AND (acc, 0x1)
42 MOV (sample, acc)
bd4f3b3e
TG
43
44 { u8 tmp;
45 tmp = i2<<3 | i1>>5;
46 tmp ^= n;
268e276e 47 g(tmp);
f345ce49
TG
48 //^TODO
49 } //tmp
5ebb16dc
TG
50 SR (acc)
51 AND (acc, i2)
52 SR (acc)
53 AND (acc, 3)
54 ADD (sample, acc)
bd4f3b3e 55
f345ce49 56 { u8 tmp2;
63fc42a5 57 tmp2 = (i2<<5|i1>>3)%3;
bd4f3b3e 58 tmp2 += n;
268e276e 59 g(tmp2);
f345ce49
TG
60 //^TODO
61 } //tmp2
5ebb16dc
TG
62 SR (acc)
63 SR (acc)
fd9dc6aa 64 { u8 tmp1 = i2/6;
5ebb16dc 65 AND (acc, tmp1)
f345ce49 66 } //tmp1
5ebb16dc
TG
67 AND (acc, 3)
68 ADD (sample, acc)
bd4f3b3e 69
f345ce49 70 { u8 tmp2 = n;
63fc42a5 71 { u8 tmp3 = (i2<<6|i1>>2)%3;
bd4f3b3e
TG
72 tmp2 -= tmp3;
73 } // tmp3
74 tmp2 += 8;
268e276e 75 g(tmp2);
f345ce49 76 } //tmp2
5ebb16dc 77 SR (acc)
fd9dc6aa 78 { u8 tmp1 = i2/10;
5ebb16dc 79 AND (acc, tmp1)
f345ce49 80 } //tmp1
5ebb16dc
TG
81 AND (acc, 3)
82 ADD (sample, acc)
bd4f3b3e 83
8a26e976 84 putchar(sample<<4);
ac66812d 85
42c6050e
TG
86 INC (i0)
87 i1 += !i0; // ADDC i1
88 i2 += !i1 && !i0; // ADDC i2
fef0e35b 89 }
c395d5c8 90}
Imprint / Impressum