new version
authorTobias Girstmair <tobi@isticktoit.net>
Thu, 4 Mar 2021 00:17:02 +0000 (01:17 +0100)
committerTobias Girstmair <tobi@isticktoit.net>
Thu, 4 Mar 2021 00:17:02 +0000 (01:17 +0100)
bsv.c

diff --git a/bsv.c b/bsv.c
index 6a8deeb9cb0d93610ceeef36c5caa2c9fd75df2a..5a222a7d18da7f3199023c7eeb5df65dd0edb958 100644 (file)
--- a/bsv.c
+++ b/bsv.c
@@ -1,21 +1,19 @@
 typedef unsigned char u8;
 
-u8 i0, i1, i2;
+u8 i0, i1, i2; //MEM
+u8 acc; //ACC
 
 u8 notes[] = {
        0x84, 0x9d, 0xb0, 0x69, 0x9d, 0x84, 0x69, 0x58,
        0x75, 0x8c, 0xb0, 0x69, 0x8c, 0x75, 0x69, 0x58
 };
 
-u8 g(u8 x, u8 t, u8 o){
+void g(u8 t){
        u8 notes_ix = t & 0x7;
        if(3&i2)
                notes_ix += 8;
        u8 result = ((i1<<8|i0)*notes[notes_ix])>>8;  // keep hi byte
-       result >>= o;
-       result &= x;
-       result &= 3;
-       return result;
+       acc = result;
 }
 void main(void){
        i0 = i1 = i2 = 0;
@@ -24,19 +22,28 @@ void main(void){
                u8 n = i2<<2 | i1>>6;
                u8 s = i2>>1;
 
-               sample = g(1,n,4);
+               g(n);
+               acc >>= 4;
+               acc &= 1&3;
+               sample = acc;
 
                { u8 tmp;
                  tmp = i2<<3 | i1>>5;
                  tmp ^= n;
-               sample += g(s,tmp,2);
+               g(tmp);
+               acc >>= 2;
+               acc &= s&3;
+               sample += acc;
                } //tmp
 
                { u8 tmp1 = s/3;
                  u8 tmp2;
                  tmp2 = (i2<<5|i1>>3)%3;
                  tmp2 += n;
-               sample += g(tmp1,tmp2,2);
+               g(tmp2);
+               acc >>= 2;
+               acc &= tmp1&3;
+               sample += acc;
                } //tmp1, tmp2
 
                { u8 tmp1 = s/5;
@@ -45,7 +52,10 @@ void main(void){
                    tmp2 -= tmp3;
                  } // tmp3
                  tmp2 += 8;
-               sample += g(tmp1,tmp2,1);
+               g(tmp2);
+               acc >>= 1;
+               acc &= tmp1&3;
+               sample += acc;
                } //tmp1, tmp2
 
                putchar(sample<<4);
Imprint / Impressum