new version
[Chiptunes.git] / foo.c
diff --git a/foo.c b/foo.c
index 7058dd77f7b4a7661af0296388cb16e56b5655ec..c8eacfffa85f8c2a74a08e5298305192b0542924 100644 (file)
--- a/foo.c
+++ b/foo.c
@@ -24,7 +24,7 @@ void g(void) {
        SUBI    (t, -8)
        skip:
        t = data[t];
-       t = ((i1<<8|i0)*t) >> o;
+       t = (((i1&0x1f)<<8|i0)*t) >> o;
        AND     (t, x)
        ANDI    (t, 3)
        RET
@@ -83,15 +83,27 @@ int main(void) {
                ADD     (acc, t)
 
                //voice 3:
-               x = s / 3;
-               t = n + (((i3&0x01)<<13 | i2<<5 | i1>>3) % 3);
+               MOV     (x, s)
+               INC     (x)
+               #define tmp o
+               x = (x*0x55)>>8;
+               #undef tmp
+               t = ((i3&0x01)<<13 | i2<<5 | i1>>3) % 3;
+               ADD     (t, n)
                LDI     (o, 10)
                RCALL   g();
                ADD     (acc, t)
 
                //voice 4:
-               x = s / 5;
-               t = 8 + n - (((i3&0x01)<<14 | i2<<6 | i1>>2) % 3);
+               MOV     (x, s)
+               INC     (x)
+               #define tmp o
+               x = (x*0x33)>>8;
+               #undef tmp
+               t = ((i3&0x01)<<14 | i2<<6 | i1>>2) % 3;
+               SUB     (t, n)
+               NEG     (t)
+               SUBI    (t, -8)
                LDI     (o, 9)
                RCALL   g();
                ADD     (acc, t)
Imprint / Impressum