BTW, your code could be made considerably faster, if you replace line
> #declare binary2=function{if(binary1,binary1,xx2*yy2)}
with line
#declare binary2=function{if(binary1,1,xx2*yy2)}
(other functions should be corrected as well).
In this case your code is as fast as mine..