AGAL quirk

by yonatan forked from it's a knot (diff: 560)
from AGALMiniAssembler.as:
if ( !isDest )
    for ( ; k <= 4; k++ )
        regmask |= cv << ( ( k - 1 ) << 1 ); // repeat last                             
♥1 | Line 37 | Modified 2011-11-07 23:00:26 | MIT License
play

ActionScript3 source code

/**
 * Copyright yonatan ( http://wonderfl.net/user/yonatan )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/wsTO
 */

// forked from yonatan's it's a knot
// forked from keim_at_Si's Metallic soft cube
package {
    import flash.display.*;
    import flash.events.*; 
    import flash.utils.*;
    import flash.text.*;
    
    import com.adobe.utils.*;
    import com.bit101.components.*;

    public class main extends TextArea {
        private var asm:AGALMiniAssembler = new AGALMiniAssembler();
        
        function main() {
            var a:String = <agal><![CDATA[
mul vt0, vt0, vc9.yyy
add v1,  vt0, vc9.yyy
]]></agal>;

            var b:String = <agal><![CDATA[
mul vt0.xyzw, vt0.xyzw, vc9.y
add v1,  vt0, vc9.y
]]></agal>;

            width = height = 465;
            var aa:ByteArray = asm.assemble("vertex", a);
            var bb:ByteArray = asm.assemble("vertex", b);
            
            var i:int;
            var same:Boolean = true;
            if(aa.length == bb.length) {
                for(i=0; i<aa.length; i++) {
                    text += aa[i] + "\t" + bb[i] + "\n";
                    same &&= aa[i] == bb[i];
                }
                text = 
                    "Shader A:" + a + 
                    "\nShader B:" + b + 
                    "\n" + (same ? "Compiled shaders are identical" : "Compiled shaders differ") + "\n" +
                    text;
            }
        }
    }
}