X-Git-Url: https://git.gir.st/Chiptunes-pms150c.git/blobdiff_plain/8a26e9766326f9cc4adc53a0554b625126b9e463..ac66812d47f5f54cddb729dd5b7c24f2dd1eaece:/bsv.c diff --git a/bsv.c b/bsv.c index 0b9d3b3..fff89f3 100644 --- a/bsv.c +++ b/bsv.c @@ -1,6 +1,7 @@ typedef unsigned char u8; int i; +u8 i0, i1, i2, i3; u8 notes[] = { 0x84, 0x9d, 0xb0, 0x69, 0x9d, 0x84, 0x69, 0x58, @@ -8,7 +9,9 @@ u8 notes[] = { }; u8 g(u8 x, u8 t, u8 o){ - u8 notes_ix = t%8 + 8*!!(3&i>>16); + u8 notes_ix = t & 0x7; + if(3&i2) + notes_ix += 8; u8 result = (i*notes[notes_ix])>>o; result &= x; result &= 3; @@ -16,10 +19,11 @@ u8 g(u8 x, u8 t, u8 o){ } void main(void){ i = 0; + i0 = i1 = i2 = i3 = 0; for(;;) { u8 sample; - u8 n = i >> 14; - u8 s = i >> 17; + u8 n = i2<<2 | i1>>6; + u8 s = i3<<7 | i2>>1; sample = g(1,n,12); { u8 tmp = n^i>>13; sample += g(s,tmp,10); @@ -33,6 +37,11 @@ void main(void){ sample += g(tmp1,tmp2,9); } //tmp1, tmp2 putchar(sample<<4); + i++; + i0++; + i1 += !i0; + i2 += !i1 && !i0; + i3 += !i2 && !i1 && !i0; } }