From 268e276ed1a211a13afbf284de6f0731001d1ce5 Mon Sep 17 00:00:00 2001 From: Tobias Girstmair Date: Thu, 4 Mar 2021 01:17:02 +0100 Subject: [PATCH 1/1] new version --- bsv.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/bsv.c b/bsv.c index 6a8deeb..5a222a7 100644 --- 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); -- 2.39.3