new version
[Chiptunes.git] / foo.c
diff --git a/foo.c b/foo.c
index 4edaa89c09d56ef77f5dc05870f303ae211cff57..6c1e73834f4ecc6d6923cf94f8b6c5412513405f 100644 (file)
--- a/foo.c
+++ b/foo.c
@@ -36,9 +36,26 @@ int main(void) {
        u8 acc;
        //TODO: clear all vars/registers
        for (;;) {
-               acc = 0;
-               n = (i2<<2 | i1>>6);
-               s = (i3<<7 | i2>>1);
+               MOV     (n, i2)
+               LSL     (n)
+               LSL     (n)
+               #define tmp acc
+               MOV     (tmp, i1)
+               SWAP    (tmp)
+               ANDI    (tmp, 0x0f)
+               LSR     (tmp)
+               LSR     (tmp)
+               OR      (n, tmp)
+               #undef tmp
+               MOV     (s, i3)
+               ROR     (s)
+               ROR     (s)
+               ANDI    (s, 0x80)
+               #define tmp acc
+               MOV     (tmp, i2)
+               LSR     (tmp)
+               OR      (s, tmp)
+               #undef tmp
 
                //voice 1:
                LDI     (x, 1)
@@ -49,7 +66,18 @@ int main(void) {
 
                //voice 2:
                MOV     (x, s)
-               t = n ^ (i2<<3 | i1>>5);
+               #define tmp o
+               MOV     (tmp, i2)
+               LSL     (tmp)
+               LSL     (tmp)
+               LSL     (tmp)
+               MOV     (t, i1)
+               SWAP    (t)
+               ANDI    (t, 0xf)
+               LSR     (t)
+               OR      (t, tmp)
+               #undef tmp
+               EOR     (t, n)
                LDI     (o, 10)
                RCALL   g();
                ADD     (acc, t)
@@ -75,5 +103,6 @@ int main(void) {
                ADC     (i1, tmp, !i0)
                ADC     (i2, tmp, !i0&&!i1)
                ADC     (i3, tmp, !i0&&!i1&&!i2)
+               #undef tmp
        }
 }
Imprint / Impressum