898 lines
17 KiB
C++
898 lines
17 KiB
C++
//Bibliotecas
|
|
#include <mem.h>
|
|
#include <mem.h>
|
|
#include<stdio.h>
|
|
#include<conio.h>
|
|
#include<math.h>
|
|
#include<graphics.h>
|
|
#include<dos.h>
|
|
#include<ctype.h>
|
|
#include<string.h>
|
|
#include<stdlib.h>
|
|
//variables constantes
|
|
#define RES_X 640
|
|
#define RES_Y 480
|
|
#define ERROR 1
|
|
#define OK 1
|
|
#define k (2*3.14159/360)
|
|
#define RADIO 255
|
|
#define SALTOS_PROFUNDOS 8
|
|
#define SALTOS_ANCHOS 7
|
|
#define BLOQUEO_RADIO 1
|
|
#define INCREMENTAL 1
|
|
#define PROFUNDIDAD_TUNEL 35
|
|
#define FACTOR_SERPIENTE 0.015F
|
|
//estructuras y tipos
|
|
typedef struct
|
|
{
|
|
unsigned char R, G, B;
|
|
|
|
} ColorValue;
|
|
typedef ColorValue VGAPaletteType[256];
|
|
VGAPaletteType Pal;
|
|
extern int far _Cdecl Svga256_fdriver[];
|
|
//funciones
|
|
int MuestraImagen( char *file );
|
|
int CargaPaleta(char *file);
|
|
void InicializaSVGA(void);
|
|
void InicializaSVGA(void);
|
|
void RellenaTablas(void);
|
|
void Put( int x, int y, char c);
|
|
void Circulo( int x, int y, int radio, int giro, int Color );
|
|
void CirculoB( int x, int y, int radio, int giro );
|
|
void TunelEstrellas(void);
|
|
void ReadPal( VGAPaletteType K );
|
|
void WritePal( VGAPaletteType K );
|
|
void CreaPaleta(void);
|
|
void letrasm(char texto[100]);
|
|
void demo1(void);
|
|
void demo2(void);
|
|
void demo3(void);
|
|
void demo4(void);
|
|
void demo5(void);
|
|
void demo6(void);
|
|
//variables externas
|
|
int huge DetectVGA256(){ return 2; }
|
|
int MuestraImagen( char *file );
|
|
int CargaPaleta(char *file );
|
|
int PERFECCION_CIRCULO = 8;
|
|
int qeu = 0;
|
|
int Incremento = -1, contador = 0;
|
|
int XSinMov[256], YSinMov[256];
|
|
int TSin[360+90];
|
|
int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,
|
|
0,1,1,0,0,1,1,0,
|
|
0,0,1,1,1,1,0,0,
|
|
0,0,0,1,1,0,0,0,
|
|
0,0,0,1,1,0,0,0,
|
|
0,0,1,1,1,1,0,0,
|
|
// la Z
|
|
0,1,1,1,1,1,1,0,
|
|
1,0,0,0,0,0,0,1,
|
|
1,0,1,0,0,1,0,1,
|
|
1,0,0,0,0,0,0,1,
|
|
1,0,1,1,1,1,0,1,
|
|
1,1,0,0,0,0,1,1,
|
|
0,1,1,1,1,1,1,0,
|
|
};
|
|
|
|
//Funcion principal
|
|
void main()
|
|
{
|
|
int gdriver=DETECT,gmode;
|
|
initgraph(&gdriver,&gmode,"c:\\program\\borlandc\\bgi");
|
|
clearviewport();
|
|
demo1();
|
|
letrasm(" GRAFICOS IMPRESIONANTEMENTE CUTRES PA LLORA");
|
|
demo2();
|
|
letrasm(" HAY VA UNA CAIDITA DE LINEAS ASEXUALES");
|
|
demo3();
|
|
letrasm(" VAMO A DADLE A LAS IMAGENES");
|
|
demo4();
|
|
letrasm(" Y QUE TAL UN TUNEL INCREIBLEBLE");
|
|
demo5();
|
|
demo6();
|
|
|
|
}
|
|
//DEMO1
|
|
void demo1()
|
|
{
|
|
char texto1[100]={"OGA MUESTRA"};
|
|
int V;
|
|
int a=0,ac1,color;
|
|
int i=0;
|
|
int n[100],l;
|
|
int c=48,c1=0,x=0,y=250;
|
|
delay(500);
|
|
//Flan
|
|
l=strlen(texto1);
|
|
for(a=0;a<l;a++)
|
|
{
|
|
if(toascii(texto1[a]-65)<14)
|
|
n[a]=toascii(texto1[a]-64);
|
|
else if(texto1[a]=='¥')
|
|
n[a]=15;
|
|
else if(texto1[a]==' ')
|
|
n[a]=0;
|
|
else
|
|
n[a]=toascii(texto1[a]-63);
|
|
}
|
|
a=0;
|
|
while(kbhit())getch();
|
|
while(y>170&&!kbhit())
|
|
{
|
|
while(a<l)
|
|
{
|
|
x=x+7;
|
|
if(letras[n[a]][c]==0||y<190) setcolor(0);
|
|
else { randomize();color=rand() %14+1;setcolor(color);}
|
|
for(i=1;i<10;i++)
|
|
{
|
|
line(x+i,1,x+i,y);
|
|
delay(1);
|
|
}
|
|
c++;
|
|
if(c==56-c1) {a++;c=48-c1;}
|
|
}
|
|
c1=c1+8;
|
|
c=c-8;
|
|
a=0;
|
|
x=0;
|
|
y=y-10;
|
|
}
|
|
sleep(1);
|
|
//Borrado
|
|
for(a=170;a<260;a++)
|
|
{
|
|
for(x=1;x<640;x++)
|
|
{
|
|
putpixel(x,a,0);
|
|
}
|
|
delay(5);
|
|
}
|
|
clearviewport();
|
|
}
|
|
|
|
//DEMO2
|
|
void demo2()
|
|
{
|
|
int b=10,p=0,i,j,cont=0,a=0,x;
|
|
char c;
|
|
while(cont<25&&!kbhit())
|
|
{
|
|
clearviewport();
|
|
x=(rand() %14)+1;
|
|
setcolor(x);
|
|
for(i=0;i<360;i++)
|
|
{
|
|
line(320+p*cos(b*i),230+p*sin(b*i),320+p*cos(b*(i+1)),230+p*sin(b*(i+1)));
|
|
a++;
|
|
if (a==4)
|
|
{
|
|
a=0;
|
|
p=p+4;
|
|
}
|
|
delay(1);
|
|
}
|
|
//nuevos valores para variables
|
|
delay(500);
|
|
b=b+1;
|
|
p=0;
|
|
cont++;
|
|
}
|
|
setcolor(0);
|
|
for(i=0;i<480;i=i+2)
|
|
{
|
|
line(0,i,640,i);
|
|
line(0,479-i,640,479-i);
|
|
delay(20);
|
|
}
|
|
}
|
|
//DEMO3
|
|
void demo3()
|
|
{
|
|
int x,y,cont=0,x1,y1;
|
|
while(cont<4&&!kbhit())
|
|
{
|
|
for(x=1;x<320;x++)
|
|
{
|
|
for(y=1;y<360;y++)
|
|
{
|
|
if(cont==0) {x1=y+160+x*cos(y);y1=x+10+x*sin(y);}
|
|
if(cont==1) {x1=y+160+x*cos(y);y1=x+10+x*tan(y);}
|
|
if(cont==2) {x1=y+160+x*cos(y);y1=x+10+x*cos(y);}
|
|
if(cont==3) {x1=y+160+x*tan(y);y1=x+10+x*sin(y);}
|
|
putpixel(x1,y1,cont+1);
|
|
}
|
|
delay(10);
|
|
}
|
|
sleep(1);
|
|
cont++;
|
|
clearviewport();
|
|
}
|
|
}
|
|
//DEMO4
|
|
void demo4()
|
|
{
|
|
|
|
// Inicializamos el modo SVGA 640*480 256 c. ( VESA )
|
|
closegraph();
|
|
InicializaSVGA();
|
|
MuestraImagen( "dac.pcx" );
|
|
sleep(5);
|
|
clearviewport();
|
|
//closegraph();
|
|
|
|
}
|
|
int MuestraImagen( char *file )
|
|
{
|
|
int alto, ancho, contador;
|
|
unsigned char byte;
|
|
FILE *fp;
|
|
|
|
CargaPaleta( file );
|
|
|
|
|
|
if ( (fp = fopen( file,"rb")) != NULL )
|
|
{
|
|
// Saltamos la cabecera
|
|
fseek( fp, 128, SEEK_SET );
|
|
|
|
for(alto=0; alto<RES_Y; alto++)
|
|
{
|
|
for(ancho=0; ancho<RES_X; )
|
|
{
|
|
byte=getc(fp);
|
|
if(byte<=0xC0)
|
|
{
|
|
putpixel (ancho, alto, byte);
|
|
ancho++;
|
|
} else {
|
|
contador=byte&0x3F; byte=getc(fp);
|
|
for(; contador>0; contador--)
|
|
{
|
|
putpixel (ancho, alto, byte);
|
|
ancho++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
fclose(fp);
|
|
|
|
} else return ERROR;
|
|
|
|
|
|
|
|
return OK;
|
|
}
|
|
int CargaPaleta(char *file)
|
|
{
|
|
int index;
|
|
FILE *fp;
|
|
|
|
if ( (fp=fopen( file, "rb" ) ) == NULL )
|
|
return ERROR;
|
|
|
|
|
|
if ( fseek( fp, -768L, SEEK_END ) == 0 )
|
|
{
|
|
for (index=0; index<256; index++)
|
|
{
|
|
// get the red component
|
|
// get the green component
|
|
// get the blue component
|
|
// set components
|
|
setrgbpalette( index, (getc(fp) >> 2), (getc(fp) >> 2), (getc(fp) >> 2) );
|
|
} // end for index
|
|
|
|
}
|
|
|
|
fclose( fp );
|
|
return OK;
|
|
}
|
|
|
|
|
|
void InicializaSVGA(void) {
|
|
|
|
int Gd = DETECT, Gm;
|
|
int Drv, errorcode;
|
|
|
|
installuserdriver("Svga256",DetectVGA256);
|
|
// registerfarbgidriver(Svga256_fdriver);
|
|
|
|
initgraph(&Gd,&Gm,"c:\\program\\borlandc\\bgi");
|
|
|
|
/* read result of initialization */
|
|
errorcode = graphresult();
|
|
|
|
if (errorcode != grOk) /* an error occurred */
|
|
{
|
|
cprintf("Graphics error: %s\n", grapherrormsg(errorcode));
|
|
cprintf("Presione una tecla para finalizar:");
|
|
getch();
|
|
exit(1); /* return with error code */
|
|
}
|
|
|
|
}
|
|
|
|
//DEMO5
|
|
void demo5()
|
|
{
|
|
int ok=0;
|
|
RellenaTablas();
|
|
// Cambiamos a modo grafico
|
|
asm mov ax, 0x13
|
|
asm int 0x10
|
|
// ¨ Porque no mejoramos la paleta 16x2 ?
|
|
CreaPaleta();
|
|
ReadPal(Pal);
|
|
{
|
|
auto int I, J;
|
|
/* // (* Use this if you want to view the palette *)
|
|
for( I=0; I<255; I++ )
|
|
{
|
|
for( J=0; J<20; J++ )
|
|
Put(I,J,I);
|
|
}
|
|
getch();
|
|
*/
|
|
}
|
|
|
|
while( kbhit() ) getch();
|
|
ok = 0;
|
|
//TUNEL
|
|
while(ok<4000&&!kbhit())
|
|
{
|
|
TunelEstrellas();
|
|
ok++;
|
|
}
|
|
// PERFECCION_CIRCULO = 360;
|
|
/*while( !ok )
|
|
{
|
|
if ( kbhit() )
|
|
switch( getch() )
|
|
{
|
|
case 13:
|
|
qeu = !qeu;
|
|
Pal[0].R = qeu ? 255:0;
|
|
Pal[0].G = qeu ? 255:0;
|
|
Pal[0].B = qeu ? 255:0;
|
|
WritePal(Pal);
|
|
break;
|
|
case 32:
|
|
getch();
|
|
break;
|
|
case 27:
|
|
ok = 1;
|
|
break;
|
|
case '+':
|
|
PERFECCION_CIRCULO++;
|
|
_fmemset( MK_FP( 0xA000, 0 ), 0, 320*200 );
|
|
break;
|
|
case '-':
|
|
PERFECCION_CIRCULO--;
|
|
if ( PERFECCION_CIRCULO < 1 ) PERFECCION_CIRCULO = 1;
|
|
_fmemset( MK_FP( 0xA000, 0 ), 0, 320*200 );
|
|
break;
|
|
}
|
|
*/
|
|
|
|
//}
|
|
|
|
// Cambiamos a modo texto
|
|
asm mov ax, 3
|
|
asm int 0x10
|
|
|
|
}
|
|
//Funcion de DEMO5
|
|
void RellenaTablas(void)
|
|
{
|
|
float angle;
|
|
|
|
angle = 0;
|
|
while( angle < 256 )
|
|
{
|
|
XSinMov[angle] = YSinMov[angle] = (int)( sin( (2*M_PI*angle*1.4)/360 ) * 360) / (2*M_PI);
|
|
YSinMov[angle] = 0;
|
|
angle+=1;
|
|
};
|
|
|
|
angle = 0;
|
|
while( angle < (360+90) )
|
|
{
|
|
TSin[angle] = (int)(sin( (2*M_PI*angle)/360 ) * 360 / (2*M_PI) );
|
|
angle+=1;
|
|
};
|
|
|
|
}
|
|
//Funcion de DEMO5
|
|
void Put( int x, int y, char c)
|
|
{
|
|
if ( x < 0 || x >= 320 ) return;
|
|
if ( y < 0 || y >= 200 ) return;
|
|
|
|
// { Written by Matt Sottile }
|
|
asm mov ax,y
|
|
asm mov bx,ax
|
|
asm shl ax,8
|
|
asm shl bx,6
|
|
asm add bx,ax
|
|
asm add bx,x
|
|
asm mov ax,0xa000
|
|
asm mov es,ax
|
|
asm mov al,c
|
|
asm mov es:[bx],al
|
|
};
|
|
//Funcion de DEMO5
|
|
// Circulo con impresi¢n de giro ( MEJORA POR JD )
|
|
void Circulo( int x, int y, int radio, int giro, int Color )
|
|
{
|
|
int angle;
|
|
|
|
for ( angle = 0; angle < 360; angle+=PERFECCION_CIRCULO )
|
|
Put( x + (radio*FACTOR_SERPIENTE*TSin[ (giro + angle)%360 + 90 ]), y + (radio*FACTOR_SERPIENTE*TSin[ (giro+angle)%360 ]), angle >= 0 && angle <= 50 ? (Color-PROFUNDIDAD_TUNEL) : Color );
|
|
|
|
};
|
|
//Funcion de DEMO5
|
|
// Circulo con impresi¢n de giro ( MEJORA POR JD )
|
|
void CirculoB( int x, int y, int radio, int giro )
|
|
{
|
|
int angle;
|
|
|
|
for ( angle = 0; angle < 360; angle+=PERFECCION_CIRCULO )
|
|
Put( x + (radio*FACTOR_SERPIENTE*TSin[ (giro + angle)%360 + 90 ]), y + (radio*FACTOR_SERPIENTE*TSin[ (giro+angle)%360 ]), 0 );
|
|
};
|
|
//Funcion de DEMO5
|
|
void TunelEstrellas(void)
|
|
{
|
|
int depth, Color;
|
|
static unsigned char ZMov = 0;
|
|
static int GiroAngular = 0;
|
|
unsigned char Movimiento = ZMov;
|
|
static Subidon = 255;
|
|
|
|
static Velocidad = 0;
|
|
// Controles de giro por JD:
|
|
// SUAVE ZMov
|
|
// DURO Movimiento
|
|
int OGiroAngular = GiroAngular = 60;
|
|
// GiroAngular = ( GiroAngular++ ) % 360;
|
|
|
|
|
|
|
|
ZMov ++;
|
|
Movimiento = ZMov;
|
|
Color = 255-PROFUNDIDAD_TUNEL;
|
|
// Color = 255;
|
|
Velocidad++;
|
|
if ( Velocidad == 5 )
|
|
{
|
|
Velocidad = 0;
|
|
// Subidon --; if ( Subidon < 255-PROFUNDIDAD_TUNEL ) Subidon = 255;
|
|
Subidon = (Subidon++)%PROFUNDIDAD_TUNEL;
|
|
}
|
|
|
|
for ( depth=0; depth<SALTOS_ANCHOS*PROFUNDIDAD_TUNEL; depth+=SALTOS_ANCHOS*INCREMENTAL, Movimiento+=SALTOS_PROFUNDOS, Color++ )
|
|
// for ( depth=INCREMENTAL*SALTOS_ANCHOS*(PROFUNDIDAD_TUNEL-1); depth>=0; depth-=SALTOS_ANCHOS*INCREMENTAL, Movimiento+=SALTOS_PROFUNDOS, Color-- )
|
|
{
|
|
/*
|
|
OGiroAngular = GiroAngular;
|
|
GiroAngular = ( GiroAngular++ ) % 360;
|
|
*/
|
|
|
|
// Borra el anterior
|
|
CirculoB( XSinMov[(unsigned char)(Movimiento-1)] + 160, YSinMov[(unsigned char)(Movimiento-1)] + 100, RADIO - depth*BLOQUEO_RADIO, OGiroAngular + 0*Movimiento );
|
|
|
|
Subidon = (Subidon++)%PROFUNDIDAD_TUNEL;
|
|
|
|
// Dibuja el nuevo circulo
|
|
// Circulo( XSinMov[Movimiento] + 160, YSinMov[Movimiento] + 100, RADIO - depth*BLOQUEO_RADIO, GiroAngular + 0*Movimiento, (Subidon >= Color && Subidon <= Color + 2 ) ? 1: Color );
|
|
Circulo( XSinMov[Movimiento] + 160, YSinMov[Movimiento] + 100, RADIO - depth*BLOQUEO_RADIO, GiroAngular + 0*Movimiento, Subidon%6 == 0 || Subidon%6 == 1 ? 1+Subidon : Color);
|
|
}
|
|
|
|
// delay(10);
|
|
}
|
|
//Funcion de DEMO5
|
|
void ReadPal( VGAPaletteType K )
|
|
{
|
|
struct REGPACK outR;
|
|
|
|
outR.r_ax = 0x1017;
|
|
outR.r_bx = 0;
|
|
outR.r_cx = 256;
|
|
outR.r_es = FP_SEG(K);
|
|
outR.r_dx = FP_OFF(K);
|
|
while( ( inport(0x03DA) & 0x08 ) == 0x08 ); // {Wait for rescan}
|
|
intr( 0x10, &outR );
|
|
};
|
|
//Funcion de DEMO5
|
|
void WritePal( VGAPaletteType K )
|
|
{
|
|
struct REGPACK outR;
|
|
|
|
outR.r_ax = 0x1012;
|
|
outR.r_bx = 0;
|
|
outR.r_cx = 256;
|
|
outR.r_es = FP_SEG(K);
|
|
outR.r_dx = FP_OFF(K);
|
|
while( ( inport(0x03DA) & 0x08 ) == 0x08 ); // {Wait for rescan}
|
|
intr( 0x10, &outR );
|
|
};
|
|
//Funcion de DEMO5
|
|
void CreaPaleta(void)
|
|
{
|
|
unsigned char I;
|
|
|
|
memset( Pal, 0, sizeof(Pal) );
|
|
|
|
Pal[1].R = 255;
|
|
Pal[1].G = 255;
|
|
Pal[1].B = 255;
|
|
|
|
Pal[255].R = 20;
|
|
Pal[255].G = 0;
|
|
Pal[255].B = 0;
|
|
for ( I=254/*MaxColor*/; I > 254-PROFUNDIDAD_TUNEL; I-- )
|
|
{
|
|
Pal[I] = Pal[I+1];
|
|
{
|
|
if ( Pal[I].R<63 ) Pal[I].R++;
|
|
if ( Pal[I].R<63 ) Pal[I].R++;
|
|
if ( (I % 2==0) && (Pal[I].G<53) ) Pal[I].G++;
|
|
if ( (I % 2==0) && (Pal[I].B<63) ) Pal[I].B++;
|
|
}
|
|
}
|
|
|
|
#ifdef TODO_GRIS
|
|
Pal[5].R = 255;
|
|
Pal[5].G = 255;
|
|
Pal[5].B = 255;
|
|
for ( I=5; I < 255; I++ )
|
|
{
|
|
Pal[I] = Pal[I-1];
|
|
{
|
|
Pal[I].R--;
|
|
Pal[I].G--;
|
|
Pal[I].B--;
|
|
}
|
|
}
|
|
#endif
|
|
|
|
Pal[255-PROFUNDIDAD_TUNEL+1].R = 0;
|
|
Pal[255-PROFUNDIDAD_TUNEL+1].G = 0;
|
|
Pal[255-PROFUNDIDAD_TUNEL+1].B = 20;
|
|
for ( I=/*MaxColor*/255-PROFUNDIDAD_TUNEL; I > 255-2*PROFUNDIDAD_TUNEL; I-- )
|
|
{
|
|
Pal[I] = Pal[I+1];
|
|
{
|
|
if ( Pal[I].B<63 ) Pal[I].B++;
|
|
if ( Pal[I].B<63 ) Pal[I].B++;
|
|
if ( (I % 2==0) && (Pal[I].G<53) ) Pal[I].G++;
|
|
if ( (I % 2==0) && (Pal[I].R<63) ) Pal[I].R++;
|
|
}
|
|
}
|
|
|
|
|
|
#ifdef TODO_BLANCO
|
|
memset( Pal, 255, sizeof(Pal) );
|
|
Pal[0].R = 0;
|
|
Pal[0].G = 0;
|
|
Pal[0].B = 0;
|
|
#endif
|
|
|
|
WritePal(Pal);
|
|
}
|
|
//DEMO6
|
|
void demo6()
|
|
{
|
|
int y;
|
|
int gdriver=DETECT,gmode;
|
|
char texto[5][100]={"Programador:Oscar","Musica:NO HAY",
|
|
"Agradecimientos a:","Jose David(el tunel es de el)",
|
|
"PROMETO MEJORAR"};
|
|
|
|
initgraph(&gdriver,&gmode,"c:\\program\\borlandc\\bgi");
|
|
clearviewport();
|
|
for(y=440;y>-70;y--)
|
|
{
|
|
setcolor(15);
|
|
if(y>1) outtextxy(230,y,texto[0]);
|
|
if(y>-20&&y<430) outtextxy(230,y+20,texto[1]);
|
|
if(y>-40&&y<420) outtextxy(230,y+40,texto[2]);
|
|
if(y>-60&&y<410) outtextxy(230,y+60,texto[3]);
|
|
delay(20);
|
|
setcolor(0);
|
|
if(y>1) outtextxy(230,y,texto[0]);
|
|
if(y>-20&&y<430) outtextxy(230,y+20,texto[1]);
|
|
if(y>-40&&y<420) outtextxy(230,y+40,texto[2]);
|
|
if(y>-60&&y<410) outtextxy(230,y+60,texto[3]);
|
|
}
|
|
clearviewport();
|
|
letrasm(" QUIERO LA REVANCHAAAAAA ZZZZZ ");
|
|
closegraph();
|
|
}
|
|
//LETRAS
|
|
void letrasm(char texto[100])
|
|
{
|
|
//Letras moviendose
|
|
int V;
|
|
int finali=8,i=0,c3=0;
|
|
int r=0,i1=0,ac3=0,c4=0;
|
|
int n[100],l;
|
|
int c=0,c1=640,x=0,y=0;
|
|
int a=0,ac1=c1,color;
|
|
randomize();
|
|
color=rand()%14+1;
|
|
l=strlen(texto);
|
|
for(a=0;a<l;a++)
|
|
{
|
|
if(toascii(texto[a]-65)<14)
|
|
n[a]=toascii(texto[a]-64);
|
|
else if(texto[a]=='¥')
|
|
n[a]=15;
|
|
else if(texto[a]==' ')
|
|
n[a]=0;
|
|
else
|
|
n[a]=toascii(texto[a]-63);
|
|
}
|
|
while(c3!=l&&!kbhit())
|
|
{
|
|
while(y<70)
|
|
{
|
|
if(c3<l)
|
|
{
|
|
if(letras[n[c3]][i]==1) setcolor(color);
|
|
else setcolor(0);
|
|
}
|
|
//V =20*sin(x*k);
|
|
outtextxy(x,200+y,"*");
|
|
if(x>=c1||c1<0) {i++;}
|
|
if(i==finali) {i=finali-8;c3++;}
|
|
x=x+10;
|
|
if(x==640)
|
|
{
|
|
c1=ac1;x=0;y=y+10;c3=ac3;c=c+8;i=c+i1;finali=c+8;}
|
|
}
|
|
|
|
x=0;y=0;
|
|
finali=8;
|
|
i=0;
|
|
c=0;
|
|
delay(10);
|
|
c1=c1-10;
|
|
ac1=c1;
|
|
if(c1<0)
|
|
{
|
|
i1=0;
|
|
if(c1>-640)
|
|
r=10;
|
|
else
|
|
r=abs(c1)-640;
|
|
while(y<r)
|
|
{
|
|
i++;
|
|
if(i==finali) {i=finali-8;c3++;}
|
|
x=x+10;
|
|
if(x==640)
|
|
{c1=ac1;x=0;y=y+10;c3=ac3;c=c+8;i=c+i1;finali=c+8;}
|
|
if(x==abs(c1)) break;
|
|
}
|
|
c4++;
|
|
}
|
|
if(c4==8) {c4=0;ac3++;ac1=0;}
|
|
y=0;x=0;
|
|
i1=i;
|
|
}
|
|
}
|