int torgbX(int color)
{
   if (color & 0xffffff00) return color >> 8;
   color=((color & 0xe0) << 16) |
         ((color & 0x1c) << 11) |
         ((color & 0x3)  << 6 );
   return color;
}

void v_linec_antialiasX(float x0,float y0,float dx,float dy,int color,int fondo,int n)
{
#ifdef dev_cpp
   v_linec(x0,y0,dx,dy,color);
   return;
#endif
   float x,y;
   float h,hperc;
   int r,g,b,pix0,pixn,pix1,colorr,colorg,colorb,fondor,fondog,fondob;
   color=torgbX(color);
   fondo=torgbX(fondo);
   colorr=(color >> 16) & 0xff;
   colorg=(color >> 8)  & 0xff;
   colorb=(color >> 0)  & 0xff;
   fondor=(fondo >> 16) & 0xff;
   fondog=(fondo >> 8)  & 0xff;
   fondob=(fondo >> 0)  & 0xff;
   if (dx<0)
   {
       x0=x0+dx;
       y0=y0+dy;
       dx=-dx;
       dy=-dy;
   }
   if (abs(dx) > (abs(dy)))
   {
      dx++;
      for (x=x0;x<(x0+dx);x++)             //pixel step x
      {
          h=y0+(float)(x-x0)/(float)dx*(dy+0);
          hperc=(h-floor(h)) * 255;
          r = (colorr * (255 - hperc) + fondor * hperc)/256;
          g = (colorg * (255 - hperc) + fondog * hperc)/256;
          b = (colorb * (255 - hperc) + fondob * hperc)/256;
          pix0=(r<<16) | (g<<8) | b;   //sotto
          r = (fondor * (255 - hperc) + colorr * hperc)/256;
          g = (fondog * (255 - hperc) + colorg * hperc)/256;
          b = (fondob * (255 - hperc) + colorb * hperc)/256;
          pix1=(r<<16) | (g<<8) | b;   //sopra
          v_linec(x,h,0,0,pix0 << 8);
          v_linec(x,h+n,0,0,pix1 << 8);
          for (y=1;y<n;y++)
          {
              r=colorr;
              g=colorg;
              b=colorb;
              pixn=(r<<16) | (g<<8) | b;
              v_linec(x,h+y,0,0,pixn << 8);
          }
      }
   }
   else if (dy > 0)
   {
      dy++;
      for (y=y0;y<(y0+dy);y++)             //pixel step x
      {
          h=x0+(float)(y-y0)/(float)dy*(dx+0);
          hperc=(h-floor(h)) * 255;
          r = (colorr * (255 - hperc) + fondor * hperc)/256;
          g = (colorg * (255 - hperc) + fondog * hperc)/256;
          b = (colorb * (255 - hperc) + fondob * hperc)/256;
          pix0=(r<<16) | (g<<8) | b;   //sotto
          r = (fondor * (255 - hperc) + colorr * hperc)/256;
          g = (fondog * (255 - hperc) + colorg * hperc)/256;
          b = (fondob * (255 - hperc) + colorb * hperc)/256;
          pix1=(r<<16) | (g<<8) | b;   //sopra
          v_linec(h,y,0,0,pix0 << 8);
          v_linec(h+n,y,0,0,pix1 << 8);
          for (x=1;x<n;x++)
          {
              r=colorr;
              g=colorg;
              b=colorb;
              pixn=(r<<16) | (g<<8) | b;
              v_linec(h+x,y,0,0,pixn << 8);
          }
      }
   }
   else
   {
      dy--;
      for (y=y0;y>(y0+dy);y--)             //pixel step x
      {
          h=x0+(float)(y-y0)/(float)dy*(dx+0);
          hperc=(h-floor(h)) * 255;
          r = (colorr * (255 - hperc) + fondor * hperc)/256;
          g = (colorg * (255 - hperc) + fondog * hperc)/256;
          b = (colorb * (255 - hperc) + fondob * hperc)/256;
          pix0=(r<<16) | (g<<8) | b;   //sotto
          r = (fondor * (255 - hperc) + colorr * hperc)/256;
          g = (fondog * (255 - hperc) + colorg * hperc)/256;
          b = (fondob * (255 - hperc) + colorb * hperc)/256;
          pix1=(r<<16) | (g<<8) | b;   //sopra
          v_linec(h,y,0,0,pix0 << 8);
          v_linec(h+n,y,0,0,pix1 << 8);
          for (x=1;x<n;x++)
          {
              r=colorr;
              g=colorg;
              b=colorb;
              pixn=(r<<16) | (g<<8) | b;
              v_linec(h+x,y,0,0,pixn << 8);
          }
      }
   }
}

void plotlogxX(float k,float minx,float maxx,int x0,int y0,float scalax,int dxh,int dyh,unsigned int color2,unsigned int color3,int n)
{
    float ii,xnew;
    float ratio = maxx/minx;
    char chii[16];
    float scalaxx=(float)dxh/(log10f(maxx)-log10f(minx));
    int k6=6;if (dxh>199)k6=10;
    for (ii=k;ii<(k*k6);ii+=k)
    {
        if (ii>minx) 
        if (ii<maxx)
        {
            float iii=ii*1000;
            xnew=x0+(log10f(ii)-log10f(minx))*scalaxx;
            v_linec(xnew,y0,0,dyh-1,color3);
            if (ii>0.9) sprintf(chii,"%ld&",(U32)ii);
            else        
            {
                sprintf(chii,"%ldmm",(U32)iii);
                ratio = 12345678;
            }   
            if (
                (((chii[0]=='1') || (chii[0]=='2') || (chii[0]=='3') || (chii[0]=='4') || (chii[0]=='5'))&&(ratio < 11)) ||
                (((chii[0]=='1') || (chii[0]=='2') || (chii[0]=='3') || (chii[0]=='5'))&&(ratio < 110)) ||
                (((chii[0]=='1') ||  (chii[0]=='5'))&&(ratio < 11000)) ||
                (((chii[0]=='1') )&&(ratio < 11000000)) ||
                ((chii[0]=='1') && (ratio == 12345678))               
            )
            {
                char *pnt;
                if (chii[0]=='1') v_linec(xnew+1,y0,0,dyh-1,color3);
                if (pnt=strstr(chii,"000000000&"))
                {
                    strcpy(pnt,"G.&");
                }
                if (pnt=strstr(chii,"000000&"))
                {
                    strcpy(pnt,"M.&");
                }
                if (pnt=strstr(chii,"000&"))
                {
                    strcpy(pnt,"K.&");
                }
                chii[strlen(chii)-1]=0;
                v_locate (xnew-2,y0+dyh+18);
                v_setfont(7,1,1);
                v_color(TRASP,color2);
                v_printf("%s",chii);
            }
        }    
    }
}

void plotlogyY(float k,float min,float max,int x0,int y00,float scalay,int dxh,int dyh,unsigned int color2,unsigned int color3)
{
    float ii,ynew;
    int k6=6;if (dyh>199)k6=10;
    if (min < k)
    {
        ii=(k);  if (ii < max)
        {
            ynew=y00+dyh-(log10f(ii)-log10f(min))*scalay;
            v_linec(x0,ynew,dxh-1,0,color3);
            v_locate (x0+dxh+2,ynew+8);
            v_setfont(7,1,1);
            v_color(TRASP,color2);
            if (ii<1000) printf("%g",ii);
            else printf("%dK",(int)(ii/1000));
            
        }
    }
    for (ii=k;ii<(k*k6);ii+=k)
    {
        if (ii > min)if (ii < max){ynew=y00+dyh-(log10f(ii)-log10f(min))*scalay;v_linec(x0,ynew,dxh-1,0,color3);}    
    }
}


U32 AutoPlot_Y2(void *vect,    //vettore delle y
    U32 n,          //n. campioni del vettore
    U32 size,       //spessore della linea con antialias
    U32 color1,     //colore grafico
    U32 color2,     //colore scala
    U32 color3,     //colore griglia
    U32 color4,     //colore fondo
    char *flags,    //LX:x log  LY:y log  db:y in dB  ang:y in gradi(es. -180...180)
    float miny,     //minimo valore y
    float maxy,     //max valore y  (se uguali scala automatica)
    float minx,     //x del primo elemento del vettore (lin & log)
    float maxx)     //x dell' ultimo elemento del vettore (lin & log)
{
    static int actual;
    static char bu[40];
    static float py=1;
    static int i=0,fuori=0,punti=0;
    static float ii=0;
    static float iii=0;
    static float scalax=0;
    static float min=0,max=0;
    static float scalay=0;
    static float offy=0;
    static float y=0,yold=0,ynew=0;
    static int sx=0;
    static int kk=0;
    
    int passoy=0;     
    int scalayok=0;  
    int autoscale=1;
    int maxl=24;
    U32 color5=0;
    U32 x0=x_x+4;
    U32 y0=y_y+8;
    U32 ret=micro_timer();
    int tipo=5;
    int fuorix=0;
    int xnew=1;
    int alias=0;
    int lx=0;
    int ly=0;
    int db=0;
    int ang=0;
    int dxh=me->width-16;
    int dyh=me->height-16;
    int nox=0,noy=0;
    int shorty=0;
    int dayweekmonth=0;
    
    dxh -= maxl;
    color5=me->rgb_color;
    if (strstr(flags,"db10"))db=10;   //y in dB (power)
    if (strstr(flags,"db20"))db=20;   //y in dB (volts)
    if (strstr(flags,"+"))
    {
       xnew=0;     //nuova curva
       kk++;
    }
    if (strstr(flags,"++")) kk=0;
    if (strstr(flags,"d")) dayweekmonth=1;   //giorno
    if (strstr(flags,"w")) dayweekmonth=2;   //giorno
    if (strstr(flags,"m")) dayweekmonth=3;   //giorno
    
    if (strstr(flags,"x")) fuorix=1;  //disegna il tratto di curva che non rientra
    if (strstr(flags,"y")) fuorix=2;  //ribalta il tratto di curva che non rientra
    if (strstr(flags,"A")) alias=1;   //antialiasing
    if (strstr(flags,"LX")) lx=1;      //x logaritmico
    if (strstr(flags,"LY")) ly=1;      //y logaritmico
    if (strstr(flags,"S"))  shorty=1;  //y corto
    if (strstr(flags,"SS"))  shorty=2;  //y corto
    if ( strstr(flags,"-X")) nox=1; else dyh-=12;     //posto per scala x
    if ( strstr(flags,"-Y")) {dxh+=22;noy=1;}         //posto per scala y
//  ============================================================================
//  ============================================================================
    {
        if (minx <=0) lx=0;
        if (maxx <=0) lx=0;
    }       
    if      (strstr(flags,"UB")) tipo=0;
    else if (strstr(flags,"UW")) tipo=1;
    else if (strstr(flags,"UD")) tipo=2;
    else if (strstr(flags,"B"))  tipo=3;
    else if (strstr(flags,"W"))  tipo=4;
    else if (strstr(flags,"D"))  tipo=5;
    else if (strstr(flags,"F"))  tipo=6;
    if      (strstr(flags,"H"))
    {
        scalayok=1;
        char *s=strstr(flags,"H")+1;
        passoy=atoi(s);
    }
    
    if (strstr(flags,"ang"))
    {
        ang=1;
        fuorix=2;
        if (miny==maxy) //y angolo
        {
            miny=-180;
            maxy= 180;
        }
    }
//  se kk>0  se maxy-miny > 4  se ang=0 salta
    if (miny != maxy)
    {
        autoscale=0;
        min=miny;
        max=maxy;
    }
    py=1;i=0;fuori=0;punti=0;ii=0;iii=0;
    scalax=0;scalay=0;
    offy=0;y=0;yold=0;ynew=0;sx=0;
    
// ======================= disegno fondo e scale ===============================   
    if(xnew)
    {
        v_rectfillc(x_x,y_y,me->width,me->height,color5);
        v_rectfillc(x_x+4,y_y+8,dxh,dyh,color4);
    }
//  scala automatica
    if (autoscale)
    {
        min=10000000;
        max=-10000000;
        for (i=0;i<n;i++)
        {
            if      (tipo==0)  y=(float)(((U8*)vect)[i]);
            else if (tipo==1)  y=(float)(((U16*)vect)[i]);
            else if (tipo==2)  y=(float)(((U32*)vect)[i]);
            else if (tipo==3)  y=(float)(((S8*)vect)[i]);
            else if (tipo==4)  y=(float)(((S16*)vect)[i]);
            else if (tipo==5)  y=(float)(((S32*)vect)[i]);
            else if (tipo==6)  y=(float)(((float*)vect)[i]);
            if (db)
            {
                if (y < 0.00001) y=0.00001;
                y = (float)db * log10f(y) ;
            }
            if (y>max) max=y;
            if (y<min) min=y;
        }
    }
    if (min <=0) ly=0;
    if (max <=0) ly=0;
// ======================= asse y lineare ======================================   
    if (ly==0)
// =============================================================================   
    {
//      calcolo passo
        {
            max =(int) max + 1;
            min =(int) min -1;
            float d=max-min;
            if(passoy) py=passoy;      
            else if(ang)
            {
                if ((dyh > 128)||(maxy < 91)) py=45.; else py=90.;
            }
            else
            {
                if (d>1000000) py=200000;
                else if (d>500000) py=100000;
                else if (d>250000) py=50000;
                else if (d>100000) py=20000;
                else if (d> 50000) py=10000;
                else if (d> 25000) py= 5000;
                else if (d> 10000) py= 2000;
                else if (d> 5000) py=1000;
                else if (d> 2500) py= 500;
                else if (d> 1000) py= 200;
                else if (d> 500) py=100;
                else if (d> 250) py= 50;
                else if (d> 100) py= 20;
                else if (d> 50) py=10;
                else if (d> 25) py= 5;
                else if (d> 10) py= 2;
                else if (d> 5) py=1;
                else if (d> 2.5) py= .5;
                else if (d> 1) py= .2;
                else if (d> .5) py=.1;
                else if (d> .25) py= .05;
                else if (d> .1) py= .02;
                else if (d> .05) py=.01;
                else if (d> .025) py= .005;
                else if (d> .01) py= .002;
                if (dyh < 140) py=py+py;
            }   
        }
        if (scalayok)
        {
            float pz=0;
            int imin;
            if      (py > 10000) pz=100000;
            else if (py > 1000) pz=10000;
            else if (py > 100) pz=1000;
            else if (py > 10) pz=100;
            else if (py > 1) pz=10;
            else if (py >.1) pz=1;
            if (pz) 
            {
                min=(min-pz)/pz;
                imin=min;
                min=imin * pz;
            }  
        }          
        scalay=(float)dyh/(max-min);
        offy=min*scalay;
        
//      disegna scala  LIN Y
        if (ly==0)
        {                          
            if (scalayok)
            {
                float iii,dista,quanti,passo=0;
                dista=py*scalay; 
                if (dista >=60)       passo=10;
                else if (dista >=30)  passo=5;
                else if (dista >=12)  passo=2;    
                v_color(0x20,0x20);  //tratteggiato 
                if (passo) if(xnew)
                {
                    if (shorty==1) 
                    {
                        for (iii=min;iii<=(max);iii+=py/passo) v_linec(x0,y0+dyh+offy-iii*scalay,8,0,color3);
                        for (iii=min;iii<=(max);iii+=py/passo) v_linec(x0+dxh-8,y0+dyh+offy-iii*scalay,8,0,color3);
                    }
                    else if (shorty==2) 
                    {
                        for (iii=min;iii<=(max);iii+=py/passo) v_linec(x0+dxh/2-6,y0+dyh+offy-iii*scalay,10,0,color3);
                    }
                    else        for (iii=min;iii<=(max);iii+=py/passo) v_linec(x0,y0+dyh+offy-iii*scalay,dxh,0,color3);
                }
                v_color(0x4,0x4);
            }
            if (xnew) for (ii=min;ii<=(max);ii+=py) v_linec(x0,y0+dyh+offy-ii*scalay,dxh,0,color3);
            if (xnew) v_linec(x0,y0+dyh+offy-max*scalay,dxh,0,color3);
//          stampa scala   LIN Y
            if (!noy && xnew)
            {
                for (iii=min;iii<=(max);iii+=py)
                {
                    if ((iii > -0.000001)&&(iii < 0.000001)) iii=0;
                    v_locate (x0+dxh+2,y0+dyh+offy-iii*scalay+8);
                    v_setfont(7,1,1);
                    v_color(4,color2);
                    char G[20];
                    if (strstr(flags,"N"))
                    {
                        static char nsow[5][6]={"Nord","Est","Sud","West","Nord"};
                        sprintf(G,"%s",nsow[(int)iii%6]);
                    }
                    else sprintf(G,"%g",iii);
                    G[6]=0;
                    printf("%s",G);
                }
            }
            if (strstr(flags,"Z"))
            {
                if(xnew) if ((max > 0) && (min < 0)) v_linec(x0,y0+dyh+offy,dxh-1,0,color5 ^ 0xffffffff);
            } 
        } 
    }
// ======================= asse x lineare ======================================   
    if (lx==0)
// =============================================================================   
    {
        volatile float dex=(maxx-minx);         //delta  max-min  MHz  100 - 5
        volatile float passo=(float)dxh/dex;    //passo di 1 MHZ;      800/95=8.42
        volatile float offs=minx;               //                     5
        volatile float mipa=0;
        volatile float multa=1;
        volatile int num=0;   
        volatile float arond;
        volatile int irond;
        scalax=(float)dxh/((float)n-1);
        sx=scalax-1;
        if (sx<0) sx=0;
        int densita=15;
        if (dayweekmonth==1) densita=30;
        if (dayweekmonth==3) densita=30;
        while (dex > densita)
        {
            if (dex > 15)
            {
                dex/=2.;                   //  9.5
                passo*=2.;                 //  84.2
                offs/=2;                   //  0.5
                multa=multa*2;
            }
            if (dex > 15)
            {
                dex/=5.;                   //  9.5
                passo*=5.;                 //  84.2
                offs/=5;                   //  0.5
                multa=multa*5;
            }
        }  
        mipa=(float)minx/(float)multa+1.;
        mipa=((int)mipa) * multa;
        offs = offs-(int)offs;
        offs = (1. - offs)*passo;
        num= dex;
        float iii;
        for (iii=0 ;iii<num;iii++)
        {
            if (!xnew) break;
            char ss[8];
            ii=iii;
            v_linec(x0+offs+passo *iii,y0,0,dyh-1,color3);
            v_locate(x0+offs+passo *ii -8,y0+dyh+18);
            v_setfont(7,1,1);
            v_color(TRASP,color2);
            arond=mipa+multa*ii;
            irond=arond;
            if (dayweekmonth)
            {
                if (dayweekmonth==1)
                {
                    int ora=(hh-(int)iii)%24;
                    if(ora< 1) ora += 24;
                    v_printf("%d",ora);
                }
            }
            else if (!nox)
            {
                char chii[16];
                char *pnt;
                sprintf(chii,"%ld&",irond);
                if (pnt=strstr(chii,"000000&"))
                {
                    strcpy(pnt,"M.&");
                }
                if (pnt=strstr(chii,"000&"))
                {
                    strcpy(pnt,"K.&");
                }
                chii[strlen(chii)-1]=0;
                v_printf("%s",chii);
            }
        } 
        v_linec(x0,y0,0,dyh-1,color3);
        v_linec(x0+dxh,y0,0,dyh-1,color3);
    }
// ======================= asse x logaritmico ==================================   
    if (lx !=0)
// =============================================================================   
    {
        float scalaxx=0;
        scalaxx=(float)dxh/(log10f(maxx)-log10f(minx));
        scalax=(float)dxh/((float)n-1);
//      disegna scala  LOG
//      scala x
        ii=minx;{float xnew=x0+(log10f(ii)-log10f(minx))*scalaxx;v_linec(xnew,y0,0,dyh-1,color3);}
        ii=maxx;{float xnew=x0+(log10f(ii)-log10f(minx))*scalaxx;v_linec(xnew,y0,0,dyh-1,color3);}
        plotlogxX(.00001,minx,maxx,x0,y0,scalax,dxh,dyh,color2,color3,n);
        plotlogxX(.0001,minx,maxx,x0,y0,scalax,dxh,dyh,color2,color3,n);
        plotlogxX(.001,minx,maxx,x0,y0,scalax,dxh,dyh,color2,color3,n);
        plotlogxX(.01,minx,maxx,x0,y0,scalax,dxh,dyh,color2,color3,n);
        plotlogxX(.1,minx,maxx,x0,y0,scalax,dxh,dyh,color2,color3,n);
        plotlogxX( 1,minx,maxx,x0,y0,scalax,dxh,dyh,color2,color3,n);
        plotlogxX( 10,minx,maxx,x0,y0,scalax,dxh,dyh,color2,color3,n);
        plotlogxX( 100,minx,maxx,x0,y0,scalax,dxh,dyh,color2,color3,n);
        plotlogxX( 1000,minx,maxx,x0,y0,scalax,dxh,dyh,color2,color3,n);
        plotlogxX( 10000,minx,maxx,x0,y0,scalax,dxh,dyh,color2,color3,n);
        plotlogxX( 100000,minx,maxx,x0,y0,scalax,dxh,dyh,color2,color3,n);
        plotlogxX( 1000000,minx,maxx,x0,y0,scalax,dxh,dyh,color2,color3,n);
        plotlogxX( 10000000,minx,maxx,x0,y0,scalax,dxh,dyh,color2,color3,n);
        v_linec(x0+dxh,y0,0,dyh-1,color3);
    }
// ======================= asse y logaritmico ==================================   
    if (ly!=0)
// =============================================================================   
    {   
//      scala y
        scalay=(float)dyh/(log10f(max)-log10f(min));
        ii=min;{float ynew=y0+dyh+offy-(log10f(ii)-log10f(min))*scalay;v_linec(x0,ynew,dxh-1,0,color3);}
        ii=max;{float ynew=y0+dyh+offy-(log10f(ii)-log10f(min))*scalay;v_linec(x0,ynew,dxh-1,0,color3);}
        plotlogyY(.0001,min,max,x0,y0+offy,scalay,dxh,dyh,color2,color3);
        plotlogyY(.001,min,max,x0,y0+offy,scalay,dxh,dyh,color2,color3);
        plotlogyY(.01,min,max,x0,y0+offy,scalay,dxh,dyh,color2,color3);
        plotlogyY(.1,min,max,x0,y0+offy,scalay,dxh,dyh,color2,color3);
        plotlogyY(1,min,max,x0,y0+offy,scalay,dxh,dyh,color2,color3);
        plotlogyY(10,min,max,x0,y0+offy,scalay,dxh,dyh,color2,color3);
        plotlogyY(100,min,max,x0,y0+offy,scalay,dxh,dyh,color2,color3);
        plotlogyY(1000,min,max,x0,y0+offy,scalay,dxh,dyh,color2,color3);
        plotlogyY(10000,min,max,x0,y0+offy,scalay,dxh,dyh,color2,color3);
        plotlogyY(100000,min,max,x0,y0+offy,scalay,dxh,dyh,color2,color3);
        plotlogyY(1000000,min,max,x0,y0+offy,scalay,dxh,dyh,color2,color3);
        plotlogyY(10000000,min,max,x0,y0+offy,scalay,dxh,dyh,color2,color3);
    }
    
//  ============================================================================
//  ============================================================================
again:
    if (strstr(flags,"P")) punti=1; else punti=0;
    for (i=0;i<n;i++)
    {
        if (tipo==0)  y=(float)(((U8*)vect)[i]);
        else if (tipo==1)  y=(float)(((U16*)vect)[i]);
        else if (tipo==2)  y=(float)(((U32*)vect)[i]);
        else if (tipo==3)  y=(float)(((S8*)vect)[i]);
        else if (tipo==4)  y=(float)(((S16*)vect)[i]);
        else if (tipo==5)  y=(float)(((S32*)vect)[i]);
        else if (tipo==6)  y=(float)(((float*)vect)[i]);
        if (db)
        {
            if (y < 0.00001) y=0.00001;
            y= (float)db * log10f(y) ;
        }
        fuori=0;
        if (ly==0)
        {
            ynew=y0+dyh+offy-y*scalay;
        }
        else
        {
            if (y < min) y = min;
            ynew=y0+dyh+offy-(log10f(y)-log10f(min))*scalay;
        }   
// =============================================================================
        if (ynew<y0)            
        {
            if (fuorix==2)
            {
                while(ynew<y0) {ynew+=dyh;}
            }
            else
            {
                ynew=y0;
                fuori++;
            }  
        }
        else if (ynew>(y0+dyh)) 
        {
            if (fuorix==2)
            {
                while(ynew>(y0+dyh)) {ynew-=dyh;}
            }
            else
            {
                ynew=y0+dyh;
                fuori++;
            }   
        }
// =============================================================================
        if (fuorix) fuori=0;  //disegna il tratto di curva che non rientra
        if (punti) yold=ynew;
        if ((i>0)&&(!fuori)&&(size))
        {
            if (lx==0)
            {
                v_linec_antialiasX(x0+(float)(i-1)*scalax,yold,sx+1,ynew-yold,color1,color4,size);
                if (i==1) actual=yold;
            }    
            else      
            {
                float scalaxx,ii1,ii2;
                scalaxx=(float)dxh/(log10f(maxx)-log10f(minx));
                ii1=minx+(maxx-minx)/(n-1)*(float)(i-1);
                ii2=minx+(maxx-minx)/(n-1)*(float)(i-0);
                ii1=(log10f(ii1)-log10f(minx))*scalaxx;;
                ii2=(log10f(ii2)-log10f(minx))*scalaxx;;
                v_linec_antialiasX(x0+ii1,yold,(ii2-ii1),ynew-yold,color1,color4,size);
                if (i==1) actual=yold;
            }
        }
// =============================================================================
        else if ((i>0)&&(!fuori))
        {
            if (lx==0)
            {
                v_linec(x0+(float)(i-1)*scalax,yold,sx+1,ynew-yold,color1);
                v_linec(x0+(float)(i-1)*scalax,yold+1,sx+1,ynew-yold,color1);
            }    
            else      
            {
                float scalaxx,ii1,ii2;
                scalaxx=(float)dxh/(log10f(maxx)-log10f(minx));
                ii1=minx+(maxx-minx)/(n-1)*(float)(i-1);
                ii2=minx+(maxx-minx)/(n-1)*(float)(i-0);
                ii1=(log10f(ii1)-log10f(minx))*scalaxx;;
                ii2=(log10f(ii2)-log10f(minx))*scalaxx;;
                v_linec(x0+ii1,yold,(ii2-ii1),ynew-yold,color1);
                v_linec(x0+ii1,yold+1,(ii2-ii1),ynew-yold,color1);
            }    
        }
        yold=ynew;
    }
//  ZOOM ---------------------------------------------------------------------------
    static int touch_x_old,touch_y_old;
    if(touch_premuto)
    {
       touch_x_old=touch_x;
       touch_y_old=touch_y;
    }
    int dove;
    if((touch_x_old > x_x)&&(touch_x_old < (x_x+me->width))&&(touch_y_old > y_y)&&(touch_y_old < (y_y+me->height)))
    {
        float   level;
        dove=((touch_x_old-4-x_x)*n)/(dxh);
        if(dove <  0) dove=0;
        if(dove >= n) dove=n-1;
        if      (tipo==0)  level=(float)(((U8*)vect)[dove]);
        else if (tipo==1)  level=(float)(((U16*)vect)[dove]);
        else if (tipo==2)  level=(float)(((U32*)vect)[dove]);
        else if (tipo==3)  level=(float)(((S8*)vect)[dove]);
        else if (tipo==4)  level=(float)(((S16*)vect)[dove]);
        else if (tipo==5)  level=(float)(((S32*)vect)[dove]);
        else if (tipo==6)  level=(float)(((float*)vect)[dove]);
        v_locate(x_x+8,y_y+34+kk*16);
        v_locate(x0+dxh/2,y_y+34+kk*16);
        v_setfont(10,1,1);
        v_color(BLACK,color1);
        printf("%g",level);
        v_linec(touch_x_old,y_y,0,me->height-2,YELLOW);
    }
//  --------------------------------------------------------------------------------
//    ret=micro_timer()-ret;
    return dove;
}


