commit a3680b0f9d20da862519dfd9c80dabe144b66042 Author: jdg Date: Wed Sep 8 20:55:57 2021 +0200 First commit 09/03/1997 diff --git a/DEMO.CPP b/DEMO.CPP new file mode 100644 index 0000000..6ff91d9 --- /dev/null +++ b/DEMO.CPP @@ -0,0 +1,906 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "demo.h" +#include "..\modex\modex.h" + +#define ERROR 1 +#define OK 0 + +char *Pato[3], *BufferV; +int LeePato( char *file, char *dir ); +void ReducePato( char *Dest, char *Org, char Magn ); + +void LeeFuentes(char *file); +void JugadorDyna( int x, int y, char mov ); +void BombaDyna( int x, int y, char mov ); +void MensajeIntermedio(char *buffer); +void FuenteAmplia( char *Frase, p_Ampliada far *FA ); +void FuenteAmplia2( char *Frase, p_Ampliada far *FA ); +void PatoSimpsons(void); + +char *ptr_char; + +int XSinMov[256], YSinMov[256]; +int TSin[360+90]; + + /**************************************************************************\ +|* *| +|* CargaPaleta *| +|* *| +|* Descripci¢n: *| +|* Carga la paleta con los colores por defecto *| +|* *| +|* *| +|* Entradas: achivo PCX de donde cargar la paleta *| +|* *| +|* Salidas: OK Todo ha ido bien *| +|* ERROR Algo va mal *| +|* *| + \**************************************************************************/ +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 + Palette256[index][0] = ( ( getc(fp) >> 2 ) )/* *63 )/255*/; + Palette256[index][1] = ( ( getc(fp) >> 2 ) )/* *63 )/255*/; + Palette256[index][2] = ( ( getc(fp) >> 2 ) )/* *63 )/255*/; + } // end for index + + } + setvgapalette256( &Palette256 ); + + + fclose( fp ); + return OK; +}; + + +void RellenaTablas(void) +{ + float angle; + + angle = 0; + while( angle < 256 ) + { + XSinMov[angle] = YSinMov[angle] = (int)( sin( (M_PI*angle*1.4)/180.0 ) * 180.0) / M_PI; + YSinMov[angle] = 0; + angle+=1; + }; + + angle = 0; + while( angle < (360+90) ) + { + TSin[angle] = (int)(sin( (M_PI*angle)/180.0 ) * 100 ); + angle+=1; + }; + +} + +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 +}; + +//#define RADIO 255 +#define RADIO 255 +//#define SALTOS_PROFUNDOS 8 +#define SALTOS_PROFUNDOS 8 +//#define SALTOS_ANCHOS 7 +#define SALTOS_ANCHOS 7 +#define BLOQUEO_RADIO 1 + + +#define INCREMENTAL 1 + +#define PROFUNDIDAD_TUNEL 35 +//#define FACTOR_SERPIENTE 0.015F +#define FACTOR_SERPIENTE 0.008594366927F + +//#define TODO_BLANCO +//#define TODO_GRIS + +int PERFECCION_CIRCULO = 8; +// 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) ); + +}; + +// 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 ); +}; + +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; + 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=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); +} + +typedef struct +{ + unsigned char R, G, B; + +} ColorValue; + +typedef ColorValue VGAPaletteType[256]; + +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 ); +}; + +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} + sync_display(); + intr( 0x10, &outR ); +}; + + VGAPaletteType Pal; +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); +} + + +#define Longitud_Despedida (64+13)*8 +void DynaFin( char *buffer, char *buffer1 ) +{ + long i; char mov, acel; + int salida, index, x, y; + + p_Ampliada Despedida = { 0, 50, 40, 2, 2, 0, 255, 255 }; + + setvgapalette256( &PaletteDyn ); + + // Mostramos el mensaje de despedia. + + i = 0; + Despedida.AX = 2; + Despedida.AY = 2; + while ( i < Longitud_Despedida ) + { + i++; + FuenteAmplia( buffer, &Despedida ); + delay(3); + }; + + i = 0; +// Despedida.y += 30; + Despedida.AX = 1; + Despedida.AY = 1; + while ( i < (28+24)*8 ) + { + i++; + FuenteAmplia( buffer1, &Despedida ); + delay(3); + }; + + delay(2000); + + // Acercamiento del mu¤eco, colocaci¢n de la bomba, y alejamiento mu¤eco + mov = 1; acel = 0; + for ( x = 320; x > -30; x -=2 ) + { + acel = (acel++) % 2; + if ( acel == 1 ) + mov = (mov++) % 3; + if ( x < 160 ) + BombaDyna( 160, 150, mov-1 ); + JugadorDyna( x, 150, mov-1 ); + delay(50); + } + + + + + + // Explosion de la bomba + // Gradiente rapidisimo hasta el blanco + Palette256[64][0] = 32; + Palette256[64][1] = 32; + Palette256[64][2] = 32; + memset( MK_FP( 0xA000, 0 ), 64, 320*200 ); + + salida = 0; + for( ; salida == 0; ) + { + for (index=100; index>=0; index--) + { + // set components + if( Palette256[index][0]<63 ) Palette256[index][0] ++; + if( Palette256[index][1]<63 ) Palette256[index][1] ++; + if( Palette256[index][2]<63 ) Palette256[index][2] ++; + if( Palette256[index][0]==63 && Palette256[index][1]==63 && Palette256[index][2]==63 ) + salida = 1; + else + salida = 0; + } // end for index + setvgapalette256( &Palette256 ); + } + + delay(2000); + + // Gradiente algo mas lento hacia el negro + salida = 0; + for( ; salida == 0; ) + { + for (index=0; index<256; index++) + { + // set components + if( Palette256[index][0]>0 ) Palette256[index][0] --; + if( Palette256[index][1]>0 ) Palette256[index][1] --; + if( Palette256[index][2]>0 ) Palette256[index][2] --; + if( Palette256[index][0]==0 && Palette256[index][1]==0 && Palette256[index][2]==0 ) + salida = 1; + else + salida = 0; + } // end for index + setvgapalette256( &Palette256 ); + delay(50); + } + + +} + + +void JugadorDyna( int x, int y, char mov ) +{ + char x1, y1; + + if ( mov < 0 ) + { + // Borra el mu¤eco anterior + + } else { + // Pinta el nuevo mu¤eco + for ( x1=0; x1 < 23; x1++ ) + for ( y1=0; y1 < 23; y1++ ) + Put( x+x1, y+y1, DynaMovs[mov][y1][x1] ); + } + +} + +void BombaDyna( int x, int y, char mov ) +{ + char x1, y1; + + if ( mov < 0 ) + { + // Borra el mu¤eco anterior + + } else { + // Pinta el nuevo mu¤eco + for ( x1=0; x1 < 16; x1++ ) + for ( y1=0; y1 < 18; y1++ ) + Put( x+x1, y+y1, BombMovs[mov][y1][x1] ); + } + +} + + +void CirculoGradiente(void) +{ + int x, y; + float angle; int radio; + + VGAPaletteType K; + + ReadPal( K ); + K[x].R =0; + K[x].G =0; + K[x].B =0; + + // Intentemos mejorar la paleta + for ( x = 1; x <= 127; x++ ) + { + K[x].R = K[x-1].R+1; + K[x].G = K[x-1].G+1; + K[x].B = K[x-1].B+1; + } + for ( x = 127; x < 256; x++ ) + { + K[x].R = K[255-x].R; + K[x].G = 0*K[255-x].G; + K[x].B = 0*K[255-x].B; + } + + + // Calculamos los circulos + for ( radio = 1; radio < 320; radio++ ) + for ( angle = 0; angle < 360; angle+=0.1 ) + { + x = 160 + (radio*sin( angle * M_PI / 180.0 )); + y = 100 + ((radio/*+20*/)*cos( (angle-15) * M_PI / 180.0 )); + if ( x >= 0 && x < 320 && y >= 0 && y < 200 ) + Put( x, y, (radio%(255/*-32*/))/*+32*/ ); + } + + clock_t start, end; + start = clock(); + while( ( ( clock() - start) / CLK_TCK ) < 30 ) + { + for ( x = 0; x < 256; x++ ) + K[x]=K[ (x+1)%255+1 ]; + WritePal( K ); + } +}; + + /*************************************************************************\ +|* *| +|* El control es poder, y aqui esta el control de todo el demo... *| +|* *| +|* *| +|* *| +|* *| +|* *| +|* *| +|* *| +|* *| +|* *| +|* *| + \*************************************************************************/ +void main(void) +{ + int ok; + + if ( ( ptr_char = (char *)malloc( 4096*sizeof(char) ) ) == NULL ) + return; + LeeFuentes( "demo.fnt" ); + + RellenaTablas(); + + // Cambiamos a modo grafico + asm mov ax, 0x13 + asm int 0x10 + + + while( kbhit() ) getch(); + + //°±±²²²ÛÛÛþþ þ þ Tunel de Estrellas (JD) þ þ þþÛÛÛ²²²±±° + PatoSimpsons(); + + MensajeIntermedio( "Que tal un poco de plasma para tus ojos" ); + + CirculoGradiente(); + + + MensajeIntermedio( "Waooo, eso ha estado bien, pero esto estar  aun mejor" ); + + //°±±²²²ÛÛÛþþ þ þ Tunel de Estrellas (JD) þ þ þþÛÛÛ²²²±±° + CreaPaleta(); // ¨ Porque no mejoramos la paleta 16x2 ? + ReadPal(Pal); + + clock_t start, end; + start = clock(); + while( ( ( clock() - start) / CLK_TCK ) < 30 ) + TunelEstrellas(); + + MensajeIntermedio( "Y por si fuera poco, miraa esto:" ); + + + //°±±²²²ÛÛÛþþ þ þ Mensaje y dyna poniendo una bomba þ þ þþÛÛÛ²²²±±° + DynaFin( " Agradecimiento a todos los que han hecho posible este demo. ", " Jose David Guillen 1997 (c)" ); + + + + // Cambiamos a modo texto + asm mov ax, 3 + asm int 0x10 +/* + gotoxy(1,1); + cprintf( "C:\\>"); + sleep(30); + cprintf( "\n\r Que no me he quedao' colgao' tio... " ); + cprintf( "\n\r -- Hasta el proximo intro -- " ); + cprintf( "\n\r Jos‚ David Guill‚n 1997 (c) " ); + cprintf( "\n\r " ); +*/ + free ( ptr_char ); +} + +void MensajeIntermedio(char *buffer) +{ + char buffer1[500]; + long i, len; + p_Ampliada Despedida = { 0, 50, 40, 1, 1, 0, 200, 200 }; + + memset( MK_FP( 0xA000, 0 ), 0, 320*200 ); + while( kbhit() ) getch(); + i = 0; + sprintf( buffer1, " %s", buffer ); + len = (strlen( buffer1 ))*8; + while ( i < len ) + { + i++; + FuenteAmplia2( buffer1, &Despedida ); + delay(3); + }; + memset( MK_FP( 0xA000, 0 ), 0, 320*200 ); +} + + + +/////ÜÜ///////////////////////////////////////////////////////////////////////////// +////Û///////////////////////////////////////////////////////////////////////////////// +/////ßÜ/////Ü/////////////////////////////////////////////////////////////////////// +//////ß///Ü////ß/Ü////////////////////////////////////////////////////////////////// +///////ß/Ü///Ü////////////////////////////////////////////////////////////////////// +////////Ü//ß////ß/////////////////////////////////////////////////////////////////// +/////////ß////Ü///////////////////////////////////////////////////////////////////// +///////////ß//////////////////////////////////////////////////////////////////////// +#define TAMx 8 +#define TAMy 16 +void FuenteAmplia( char *Frase, p_Ampliada far *FA ) +{ + int i, j, k; // Variables de avance + int c_elec; // Color en el momento de imprimir + int PosX, PosY; // Posicion fisica final + char LCaract; // Caracter de linea a tratar + + if ( FA->Flen != _fstrlen( Frase ) ) // Reseteamos las variables de control interno + { + // Obtenemos la longitud de la frase. ( En d¡gitos ) + FA -> Flen = _fstrlen( Frase ); + // Contador de digito actual a cero + FA -> BitByte = 0; + // Posicion dentro de la frase + FA -> currByte = 0; + } + + // Avance horizontal de bit's ( avance de digitos ) + for ( i = 0; i < ( TAMx * (FA -> ndigitos) ); i++ ) + { + k = ( Frase[ ( (i+FA->BitByte)/TAMx + FA -> currByte ) % FA->Flen ] ) << 4; + LCaract = ( (char)0x01 << (7 - (i+FA->BitByte)%TAMx) ); + PosX = FA -> x + FA->AX * i; // Posicion f¡sica horizontal + // Avance vertical de bit's + for ( j = 0; j < TAMy; j ++ ) + { + PosY = FA -> y + FA->AY * j; // Posicion f¡sica vertical + + if ( ptr_char[ k + j ] & LCaract ) + c_elec = FA->C2; + else + c_elec = FA->C1; + + Put ( PosX, PosY, c_elec ); + } + } + // Tenemos en cuenta el avance dentro de la frase + if ( ( FA -> BitByte ++ ) >= 7 ) + { + FA -> BitByte = 0; FA -> currByte ++; + if ( FA -> currByte >= FA -> Flen ) + FA -> currByte = 0; + } + +} +#undef TAMy +#undef TAMx + + +#define TAMx 8 +#define TAMy 16 +void FuenteAmplia2( char *Frase, p_Ampliada far *FA ) +{ + int i, j, k; // Variables de avance + int c_elec; // Color en el momento de imprimir + int PosX, PosY; // Posicion fisica final + char LCaract; // Caracter de linea a tratar + + if ( FA->Flen != _fstrlen( Frase ) ) // Reseteamos las variables de control interno + { + // Obtenemos la longitud de la frase. ( En d¡gitos ) + FA -> Flen = _fstrlen( Frase ); + // Contador de digito actual a cero + FA -> BitByte = 0; + // Posicion dentro de la frase + FA -> currByte = 0; + } + + // Avance horizontal de bit's ( avance de digitos ) + for ( i = 0; i < ( TAMx * (FA -> ndigitos) ); i++ ) + { + k = ( Frase[ ( (i+FA->BitByte)/TAMx + FA -> currByte ) % FA->Flen ] ) << 4; + LCaract = ( (char)0x01 << (7 - (i+FA->BitByte)%TAMx) ); + PosX = FA -> x + FA->AX * i; // Posicion f¡sica horizontal + // Avance vertical de bit's + for ( j = 0; j < TAMy; j ++ ) + { + PosY = FA -> y + FA->AY * j; // Posicion f¡sica vertical + + if ( ptr_char[ k + j ] & LCaract ) + c_elec = /*FA->C2*/PosX; + else + c_elec = FA->C1; + + Put ( PosX, PosY, c_elec ); + } + } + // Tenemos en cuenta el avance dentro de la frase + if ( ( FA -> BitByte ++ ) >= 7 ) + { + FA -> BitByte = 0; FA -> currByte ++; + if ( FA -> currByte >= FA -> Flen ) + FA -> currByte = 0; + } + +} +#undef TAMy +#undef TAMx + +/* Setvgapalette256 sets the entire 256 color palette */ +/* PalBuf contains RGB values for all 256 colors */ +/* R,G,B values range from 0 to 63 */ +/* Usage: */ +/* DacPalette256 dac256; */ +/* */ +/* setvgapalette256(&dac256); */ +void setvgapalette256(DacPalette256 *PalBuf) +{ + struct REGPACK reg; + + reg.r_ax = 0x1012; + reg.r_bx = 0; + reg.r_cx = 256; + reg.r_es = FP_SEG(PalBuf); + reg.r_dx = FP_OFF(PalBuf); +// while( ( inport(0x03DA) & 0x08 ) == 0x08 ); // {Wait for rescan} + sync_display(); + intr(0x10,®); +} + + /*************************************************************************\ +|* *| +|* LeeFuentes *| +|* *| +|* Descripcion: *| +|* Lee el conjunto de fuentes del archivo especificado *| +|* *| +|* Entradas: puntero al nombre del archivo *| +|* *| +|* Salidas: (ninguna) *| +|* *| + \*************************************************************************/ +void LeeFuentes(char *file) +{ +FILE *fich; + /* Reservamos 4 Kb. para cargar la fuente en memoria */ + + /* Abrimos el fichero de la fuente */ + + if ((fich=fopen(file,"rb"))==NULL) { + printf("\a\nArchivo %s no encontrado.\n",file); + exit(1); + } + + fseek(fich, SEEK_SET, 0); /* Nos colocamos al principio del fichero */ + fread(ptr_char,1,4096,fich); /* Cargamos en memoria 4096 bytes del fichero */ + fclose(fich); /* Cerramos el fichero */ +} + +#define RESP_X 151 +#define RESP_Y 141 + + + +void PatoSimpsons(void) +{ + FILE *handle; + char *Buffer2; + int byteRot; + int x, y, mov, i, ok; + // Pido memoria para los tres patos 151x141 + if ( ( Pato[0] = (char *)malloc( sizeof(char)*155*145 ) ) == NULL || + ( Pato[1] = (char *)malloc( sizeof(char)*155*145 ) ) == NULL || + ( Pato[2] = (char *)malloc( sizeof(char)*155*145 ) ) == NULL || + ( Buffer2 = (char *)malloc( sizeof(char)*320*200 ) ) == NULL || + ( BufferV = (char *)malloc( sizeof(char)*320*200 ) ) == NULL + ) { + printf( "\a" ); + return; + } + +// Buffer2 = (char *)MK_FP( 0xA000, 0 ); + + // Inicializamos la paleta + CargaPaleta( "Pat0.pcx" ); + // Leemos los patos + LeePato( "Pat0.pcx", Pato[0] ); + // Muestra el primer pato mientras acabamos los c lculos + for ( x = 0; x < RESP_X; x ++ ) + for ( y = 0; y < RESP_Y; y ++ ) + Put( x+85, y+50, Pato[0][x + RESP_X*y] ); + LeePato( "Pat1.pcx", Pato[1] ); + LeePato( "Pat2.pcx", Pato[2] ); + + i = 0; + while ( i < 5*6 ) + { + i++; + mov = (mov++) % 6; + for ( x = 0; x < RESP_X; x ++ ) + for ( y = 0; y < RESP_Y; y ++ ) + Put( x+85, y+50, Pato[ mov > 3 ? (6 - mov) : (mov-1) ][x + RESP_X*y] ); + delay( 100 ); + } + + // Tatatam tam + sync_display(); memset( MK_FP( 0xA000, 0 ), 255, 320*200 ); delay( 50 ); sync_display(); memset( MK_FP( 0xA000, 0 ), 0, 320*200 ); delay( 50 ); + sync_display(); memset( MK_FP( 0xA000, 0 ), 255, 320*200 ); delay( 50 ); sync_display(); memset( MK_FP( 0xA000, 0 ), 0, 320*200 ); delay( 150 ); + sync_display(); memset( MK_FP( 0xA000, 0 ), 255, 320*200 ); delay( 50 ); sync_display(); memset( MK_FP( 0xA000, 0 ), 0, 320*200 ); + + // Patos reduciendoce: + i = 1; ok = 0; byteRot = 0; + int inc = 1, fVel = 0; +float CosAngle, SinAngle; +int xc, yc; + + clock_t start, end; + start = clock(); + while( ( ( clock() - start) / CLK_TCK ) < 30 ) + { + fVel = (fVel++)%3; + if ( fVel==1 ) + { + i += inc; if ( i > 6 ) inc = -1; else if ( i < 2 ) inc = 1; + } + ReducePato( BufferV, Pato[ mov > 3 ? (6 - mov) : (mov-1) ], i ); + mov = (mov++) % 6; + + /* + Que tal una peque¤a rotaci¢n: + */ + byteRot = (byteRot+=8) % 360; +CosAngle = TSin[ byteRot + 90 ] / 100.0; +SinAngle = TSin[ byteRot ] / 100.0; + + for ( x = 0; x < 320; x++ ) +// for ( y = 0; y < 200; y++ ) + for ( y = 0; y < 200; y++ ) + { + xc = x - 160; + yc = y - 100; + + yc = xc * SinAngle + yc * CosAngle + 100; + if ( yc >= 0 && yc < 200 ) + { + xc = xc * CosAngle - ( y - 100 ) * SinAngle + 160; + if ( xc >= 0 && xc < 320 ) + { + Buffer2[ x + 320*y ] = BufferV[ xc + 320 * yc ]; + } else Buffer2[ x + 320*y ] = 0; + } else Buffer2[ x + 320*y ] = 0; + } + sync_display(); memcpy( MK_FP( 0xA000, 0 ), Buffer2, 320*200 ); + delay( 100 ); + }; + + free( Pato[0] ); + free( Pato[1] ); + free( Pato[2] ); + free( BufferV ); +// free( Buffer2 ); +} + +void ReducePato( char *Dest, char *Org, char Magn ) +{ + int x, y; + int xR, yR; + + // Escalamos el primer pato y despues... + for ( x = 0, xR = 0; x < RESP_X; x +=Magn, xR++ ) + for ( y = 0, yR = 0; y < RESP_Y; y +=Magn, yR++ ) + Dest[xR + yR*320] = Org[x + y*RESP_X]; + + // Copiamos en el destino tantos patos reducidos como podamos + // como la ovejita Dolly, pero con patos: a clonar se ha dicho... + for ( x = 0; x < 320; x++ ) + for ( y = 0; y < 200; y++ ) +// for ( y = 0; y < 320; y++ ) + + Dest[x + y*320] = Dest[ (x%xR) + (y%yR)*320 ]; + + +} + + +int LeePato( char *file, char *dir ) +{ + int alto, ancho, contador; + unsigned char byte; + FILE *fp; + + if ( (fp = fopen( file,"rb")) != NULL ) + { + // Saltamos la cabecera + fseek( fp, 128, SEEK_SET ); + + for(alto=0; alto0; contador--) + { +// set_point (ancho, alto, byte); +// ProcesaPunto( ancho, alto, byte ); + dir[ancho + alto*RESP_X] = byte; + ancho++; + } + } + } + } + fclose(fp); + } else return ERROR; + + return OK; +} diff --git a/DEMO.EXE b/DEMO.EXE new file mode 100644 index 0000000..1f8349f Binary files /dev/null and b/DEMO.EXE differ diff --git a/DEMO.FNT b/DEMO.FNT new file mode 100644 index 0000000..d88e1cd Binary files /dev/null and b/DEMO.FNT differ diff --git a/DEMO.H b/DEMO.H new file mode 100644 index 0000000..37d9aeb --- /dev/null +++ b/DEMO.H @@ -0,0 +1,425 @@ +typedef struct + { + int x, y; // Coordenadas iniciales de muestreo + char ndigitos; // n£mero de digitos a mostrar + char AX, AY; // factor de espaciado + char C1, C2, C3; // colores de fondo, texto, borde + + // Datos privados y uso interno exclusivamente + unsigned int Flen; // longitud de la frase actual + char BitByte; // bit del byte por el que va en el recorrido + char currByte; // byte actual dentro de la frase + } p_Ampliada; + + +typedef unsigned char DacPalette256[256][3]; + +void setvgapalette256(DacPalette256 *PalBuf); + + +// Paleta para el Dyna ( apartir del 50 podemos tocar los gradientes ) +DacPalette256 Palette256; +DacPalette256 PaletteDyn = { + { 0, 00, 00 }, + { 32, 00, 00 }, + { 0, 32, 00 }, + { 32, 32, 00 }, + { 0, 00, 32 }, + { 32, 00, 32 }, + { 0, 32, 32 }, + { 48, 48, 48 }, + { 48, 55, 48 }, + { 41, 50, 60 }, + { 0, 00, 00 }, + { 42, 00, 00 }, + { 53, 00, 00 }, + { 0, 10, 00 }, + { 21, 10, 00 }, + { 32, 10, 00 }, + { 42, 10, 00 }, + { 53, 10, 00 }, + { 63, 10, 00 }, + { 0, 21, 00 }, + { 21, 21, 00 }, + { 32, 21, 00 }, + { 42, 21, 00 }, + { 53, 21, 00 }, + { 63, 21, 00 }, + { 21, 32, 00 }, + { 42, 32, 00 }, + { 53, 32, 00 }, + { 63, 32, 00 }, + { 0, 42, 00 }, + { 21, 42, 00 }, + { 32, 42, 00 }, + { 42, 42, 00 }, + { 53, 42, 00 }, + { 63, 42, 00 }, + { 0, 53, 00 }, + { 21, 53, 00 }, + { 32, 53, 00 }, + { 42, 53, 00 }, + { 53, 53, 00 }, + { 63, 53, 00 }, + { 21, 63, 00 }, + { 32, 63, 00 }, + { 42, 63, 00 }, + { 53, 63, 00 }, + { 21, 00, 21 }, + { 32, 00, 21 }, + { 42, 00, 21 }, + { 53, 00, 21 }, + { 63, 00, 21 }, + { 0, 10, 21 }, + { 21, 10, 21 }, + { 32, 10, 21 }, + { 42, 10, 21 }, + { 53, 10, 21 }, + { 63, 10, 21 }, + { 0, 21, 21 }, + { 21, 21, 21 }, + { 32, 21, 21 }, + { 42, 21, 21 }, + { 53, 21, 21 }, + { 63, 21, 21 }, + { 0, 32, 21 }, + { 21, 32, 21 }, + { 32, 32, 21 }, + { 42, 32, 21 }, + { 53, 32, 21 }, + { 63, 32, 21 }, + { 0, 42, 21 }, + { 21, 42, 21 }, + { 32, 42, 21 }, + { 42, 42, 21 }, + { 53, 42, 21 }, + { 63, 42, 21 }, + { 0, 53, 21 }, + { 21, 53, 21 }, + { 32, 53, 21 }, + { 42, 53, 21 }, + { 53, 53, 21 }, + { 63, 53, 21 }, + { 0, 63, 21 }, + { 21, 63, 21 }, + { 32, 63, 21 }, + { 42, 63, 21 }, + { 53, 63, 21 }, + { 63, 63, 21 }, + { 21, 00, 32 }, + { 42, 00, 32 }, + { 53, 00, 32 }, + { 63, 00, 32 }, + { 0, 10, 32 }, + { 21, 10, 32 }, + { 32, 10, 32 }, + { 42, 10, 32 }, + { 53, 10, 32 }, + { 63, 10, 32 }, + { 0, 21, 32 }, + { 21, 21, 32 }, + { 32, 21, 32 }, + { 42, 21, 32 }, + { 53, 21, 32 }, + { 63, 21, 32 }, + { 21, 32, 32 }, + { 42, 32, 32 }, + { 53, 32, 32 }, + { 63, 32, 32 }, + { 0, 42, 32 }, + { 21, 42, 32 }, + { 32, 42, 32 }, + { 42, 42, 32 }, + { 53, 42, 32 }, + { 63, 42, 32 }, + { 0, 53, 32 }, + { 21, 53, 32 }, + { 32, 53, 32 }, + { 42, 53, 32 }, + { 53, 53, 32 }, + { 63, 53, 32 }, + { 0, 63, 32 }, + { 21, 63, 32 }, + { 32, 63, 32 }, + { 42, 63, 32 }, + { 53, 63, 32 }, + { 63, 63, 32 }, + { 00, 00, 42 }, + { 21, 00, 42 }, + { 32, 00, 42 }, + { 42, 00, 42 }, + { 53, 00, 42 }, + { 63, 00, 42 }, + { 00, 10, 42 }, + { 21, 10, 42 }, + { 32, 10, 42 }, + { 42, 10, 42 }, + { 53, 10, 42 }, + { 63, 10, 42 }, + { 00, 21, 42 }, + { 21, 21, 42 }, + { 32, 21, 42 }, + { 42, 21, 42 }, + { 53, 21, 42 }, + { 63, 21, 42 }, + { 00, 32, 42 }, + { 21, 32, 42 }, + { 32, 32, 42 }, + { 42, 32, 42 }, + { 53, 32, 42 }, + { 63, 32, 42 }, + { 00, 42, 42 }, + { 21, 42, 42 }, + { 32, 42, 42 }, + { 42, 42, 42 }, + { 53, 42, 42 }, + { 63, 42, 42 }, + { 00, 53, 42 }, + { 21, 53, 42 }, + { 32, 53, 42 }, + { 42, 53, 42 }, + { 53, 53, 42 }, + { 63, 53, 42 }, + { 00, 63, 42 }, + { 21, 63, 42 }, + { 32, 63, 42 }, + { 42, 63, 42 }, + { 53, 63, 42 }, + { 63, 63, 42 }, + { 00, 00, 53 }, + { 21, 00, 53 }, + { 32, 00, 53 }, + { 42, 00, 53 }, + { 53, 00, 53 }, + { 63, 00, 53 }, + { 00, 10, 53 }, + { 21, 10, 53 }, + { 32, 10, 53 }, + { 42, 10, 53 }, + { 53, 10, 53 }, + { 63, 10, 53 }, + { 00, 21, 53 }, + { 21, 21, 53 }, + { 32, 21, 53 }, + { 42, 21, 53 }, + { 53, 21, 53 }, + { 63, 21, 53 }, + { 00, 32, 53 }, + { 21, 32, 53 }, + { 32, 32, 53 }, + { 42, 32, 53 }, + { 53, 32, 53 }, + { 63, 32, 53 }, + { 00, 42, 53 }, + { 21, 42, 53 }, + { 32, 42, 53 }, + { 42, 42, 53 }, + { 53, 42, 53 }, + { 63, 42, 53 }, + { 00, 53, 53 }, + { 21, 53, 53 }, + { 32, 53, 53 }, + { 42, 53, 53 }, + { 53, 53, 53 }, + { 63, 53, 53 }, + { 00, 63, 53 }, + { 21, 63, 53 }, + { 32, 63, 53 }, + { 42, 63, 53 }, + { 53, 63, 53 }, + { 63, 63, 53 }, + { 21, 00, 63 }, + { 32, 00, 63 }, + { 42, 00, 63 }, + { 53, 00, 63 }, + { 00, 10, 63 }, + { 21, 10, 63 }, + { 32, 10, 63 }, + { 42, 10, 63 }, + { 53, 10, 63 }, + { 63, 10, 63 }, + { 00, 21, 63 }, + { 21, 21, 63 }, + { 32, 21, 63 }, + { 42, 21, 63 }, + { 53, 21, 63 }, + { 63, 21, 63 }, + { 00, 32, 63 }, + { 21, 32, 63 }, + { 32, 32, 63 }, + { 42, 32, 63 }, + { 53, 32, 63 }, + { 63, 32, 63 }, + { 00, 42, 63 }, + { 21, 42, 63 }, + { 32, 42, 63 }, + { 42, 42, 63 }, + { 53, 42, 63 }, + { 63, 42, 63 }, + { 00, 53, 63 }, + { 21, 53, 63 }, + { 32, 53, 63 }, + { 42, 53, 63 }, + { 53, 53, 63 }, + { 63, 53, 63 }, + { 21, 63, 63 }, + { 32, 63, 63 }, + { 42, 63, 63 }, + { 53, 63, 63 }, + { 63, 62, 60 }, + { 40, 40, 41 }, + { 32, 32, 32 }, + { 63, 00, 00 }, + { 00, 63, 00 }, + { 63, 63, 00 }, + { 00, 00, 63 }, + { 63, 00, 63 }, + { 00, 63, 63 }, + { 63, 63, 63 } + }; + + + +//unsigned char BombMovs[16][18][3] = { + +// BLOQUE / FILA / COLUMNA +unsigned char BombMovs[3][18][16] = { + { + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 12, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 12, 12, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 12, 10, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 0, 10, 255, 10, 0, 0 }, + { 0, 0, 0, 0, 10, 10, 51, 255, 51, 51, 10, 255, 33, 10, 0, 0 }, + { 0, 0, 0, 10, 51, 0, 51, 13, 51, 13, 10, 0, 10, 0, 0, 0 }, + { 0, 0, 10, 51, 255, 51, 13, 51, 51, 51, 51, 10, 10, 10, 0, 0 }, + { 0, 0, 10, 0, 255, 13, 51, 13, 51, 13, 51, 13, 51, 10, 0, 0 }, + { 0, 10, 51, 255, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 10, 0 }, + { 0, 10, 51, 0, 51, 13, 51, 13, 51, 13, 51, 13, 51, 13, 10, 0 }, + { 0, 10, 13, 51, 51, 51, 13, 51, 51, 51, 13, 51, 51, 51, 10, 0 }, + { 0, 10, 51, 13, 51, 13, 51, 13, 51, 13, 51, 13, 51, 13, 10, 0 }, + { 0, 0, 10, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 10, 0, 0 }, + { 0, 0, 10, 13, 51, 13, 51, 13, 51, 13, 51, 13, 51, 10, 0, 0 }, + { 0, 0, 0, 10, 51, 51, 13, 51, 51, 51, 51, 51, 10, 0, 0, 0 }, + { 0, 0, 0, 0, 10, 10, 51, 13, 51, 13, 10, 10, 0, 0, 0, 0 } + }, + { + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 33 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 33, 0, 12 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 12, 10 }, + { 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 0, 10, 10, 255, 10 }, + { 0, 0, 0, 0, 10, 10, 10, 51, 255, 51, 51, 10, 255, 255, 33, 10 }, + { 0, 0, 0, 10, 51, 51, 51, 51, 13, 51, 13, 10, 0, 0, 10, 0 }, + { 0, 0, 10, 51, 13, 51, 51, 13, 0, 51, 51, 51, 10, 10, 10, 10 }, + { 0, 0, 10, 51, 51, 51, 13, 255, 255, 51, 13, 51, 13, 13, 51, 10 }, + { 0, 10, 51, 51, 51, 51, 0, 255, 255, 51, 51, 51, 51, 51, 51, 51 }, + { 0, 10, 51, 13, 13, 51, 255, 51, 13, 51, 13, 51, 13, 13, 51, 13 }, + { 0, 10, 51, 51, 51, 51, 0, 51, 13, 51, 13, 51, 13, 13, 51, 13 }, + { 0, 10, 13, 51, 51, 51, 0, 13, 51, 51, 51, 13, 51, 51, 51, 51 }, + { 0, 10, 51, 13, 51, 51, 13, 51, 13, 51, 13, 51, 13, 13, 51, 13 }, + { 0, 0, 10, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 10 }, + { 0, 0, 10, 13, 51, 51, 13, 51, 13, 51, 13, 51, 13, 13, 51, 10 }, + { 0, 0, 0, 10, 51, 51, 51, 13, 51, 51, 51, 51, 51, 51, 10, 0 }, + { 0, 0, 0, 0, 10, 10, 10, 51, 13, 51, 13, 10, 10, 10, 0, 0 } + }, + { + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 12, 0 }, + { 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 12 }, + { 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 12, 10 }, + { 0, 10, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 0, 10, 255, 10 }, + { 0, 10, 0, 0, 0, 0, 10, 10, 51, 51, 51, 51, 10, 255, 33, 10 }, + { 0, 10, 0, 0, 0, 10, 51, 13, 51, 13, 255, 13, 10, 0, 10, 0 }, + { 0, 10, 0, 0, 10, 51, 13, 51, 13, 51, 51, 51, 51, 10, 10, 10 }, + { 0, 10, 0, 0, 10, 13, 13, 13, 51, 13, 51, 255, 255, 13, 51, 10 }, + { 0, 10, 0, 10, 51, 13, 51, 51, 51, 51, 51, 51, 51, 0, 51, 51 }, + { 0, 10, 0, 10, 51, 13, 51, 13, 51, 13, 51, 13, 51, 13, 255, 13 }, + { 0, 10, 0, 10, 13, 51, 51, 51, 13, 51, 51, 51, 51, 51, 0, 51 }, + { 0, 10, 0, 10, 51, 13, 51, 13, 51, 13, 51, 13, 51, 13, 0, 13 }, + { 0, 10, 0, 0, 10, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 10 }, + { 0, 10, 0, 0, 10, 13, 51, 13, 51, 13, 51, 13, 51, 13, 51, 10 }, + { 0, 10, 0, 0, 0, 10, 51, 51, 13, 51, 51, 51, 51, 51, 10, 0 }, + { 0, 10, 0, 0, 0, 0, 10, 10, 51, 13, 51, 13, 10, 10, 0, 0 }, + } + }; + +unsigned char DynaMovs[3][23][23] = { + { + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 10, 10, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 0, 10, 10, 1, 11, 12, 12, 11, 11, 10, 0, 0, 10, 29, 35, 10, 0, }, + { 0, 0, 0, 0, 0, 0, 10, 11, 11, 12, 12, 12, 12, 12, 11, 11, 10, 10, 10, 35, 29, 10, 0, }, + { 0, 0, 0, 0, 0, 0, 10, 11, 12, 12, 12, 12, 12, 12, 12, 11, 11, 10, 0, 10, 10, 0, 0, }, + { 0, 0, 0, 0, 0, 10, 23, 24, 23, 24, 23, 11, 12, 12, 12, 12, 11, 10, 0, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 10, 24, 33, 10, 28, 28, 23, 11, 12, 12, 12, 12, 10, 0, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 10, 23, 28, 10, 28, 33, 24, 11, 12, 12, 12, 11, 10, 0, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 10, 24, 28, 10, 33, 28, 24, 11, 12, 12, 12, 11, 10, 0, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 10, 23, 24, 23, 24, 23, 11, 12, 12, 12, 11, 10, 10, 0, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 10, 12, 12, 12, 10, 10, 10, 11, 11, 10, 10, 0, 0, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 17, 28, 17, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 10, 12, 18, 10, 28, 28, 28, 10, 11, 10, 0, 0, 0, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 10, 12, 17, 10, 33, 28, 23, 10, 1, 10, 0, 0, 0, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 10, 33, 28, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 10, 12, 17, 10, 29, 35, 29, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 0, 0, 10, 28, 33, 28, 33, 28, 10, 0, 0, 0, 0, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 10, 10, 10, 10, 35, 29, 35, 29, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, } + }, + { + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 0, 0, 0, 10, 10, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 1, 11, 12, 12, 11, 11, 10, 0, 10, 35, 29, 10, 0, }, + { 0, 0, 0, 0, 0, 0, 0, 10, 11, 12, 12, 12, 12, 12, 12, 12, 11, 10, 10, 29, 35, 10, 0, }, + { 0, 0, 0, 0, 0, 0, 10, 11, 12, 12, 12, 12, 12, 12, 12, 12, 11, 10, 10, 10, 10, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 10, 23, 24, 23, 11, 12, 12, 12, 12, 12, 12, 1, 10, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 10, 24, 10, 28, 24, 11, 12, 12, 12, 12, 12, 11, 10, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 10, 23, 10, 33, 24, 11, 12, 12, 12, 12, 12, 11, 10, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 10, 24, 10, 28, 24, 11, 12, 12, 12, 12, 12, 11, 10, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 10, 23, 24, 23, 11, 12, 12, 12, 12, 12, 11, 10, 10, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 10, 10, 10, 1, 11, 12, 12, 10, 10, 10, 11, 10, 10, 0, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 10, 29, 35, 10, 10, 10, 10, 10, 28, 23, 18, 10, 10, 0, 0, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 10, 35, 10, 10, 18, 24, 18, 10, 24, 28, 24, 18, 10, 10, 0, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 10, 28, 10, 18, 23, 18, 17, 10, 23, 28, 10, 35, 10, 0, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 10, 28, 10, 33, 28, 10, 10, 10, 10, 10, 35, 29, 10, 0, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 10, 10, 18, 17, 18, 17, 18, 12, 10, 10, 10, 0, 0, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 0, 10, 10, 28, 33, 24, 12, 12, 12, 10, 35, 10, 0, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 10, 10, 10, 28, 33, 24, 17, 10, 10, 10, 10, 35, 10, 0, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 10, 35, 35, 10, 24, 18, 10, 10, 28, 28, 10, 29, 10, 0, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 10, 29, 35, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, } + }, + { + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 0, 0, 10, 10, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 1, 11, 12, 12, 12, 11, 11, 10, 10, 35, 35, 10, 0, }, + { 0, 0, 0, 0, 0, 0, 0, 0, 10, 11, 12, 12, 12, 12, 12, 12, 12, 11, 10, 35, 29, 10, 0, }, + { 0, 0, 0, 0, 0, 0, 0, 0, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 11, 10, 10, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 0, 10, 23, 24, 23, 24, 23, 24, 23, 11, 12, 12, 11, 10, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 0, 10, 10, 33, 28, 10, 28, 33, 28, 24, 11, 12, 11, 10, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 0, 10, 10, 28, 33, 10, 33, 28, 33, 24, 11, 12, 12, 10, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 0, 10, 10, 28, 28, 10, 28, 28, 28, 24, 11, 12, 11, 10, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 0, 10, 23, 24, 23, 24, 23, 24, 23, 11, 12, 12, 1, 10, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 18, 10, 10, 10, 1, 11, 12, 1, 10, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 0, 10, 29, 35, 10, 10, 23, 18, 10, 10, 10, 10, 10, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 0, 10, 35, 10, 24, 33, 28, 24, 10, 24, 12, 10, 18, 10, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 0, 10, 10, 24, 33, 28, 23, 18, 10, 24, 12, 10, 17, 18, 10, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 28, 24, 18, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 0, 0, 10, 18, 10, 10, 10, 18, 17, 18, 17, 10, 10, 35, 10, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 10, 10, 18, 28, 18, 17, 18, 18, 12, 33, 24, 10, 10, 10, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 10, 29, 10, 33, 28, 23, 10, 10, 10, 23, 28, 33, 24, 10, 0, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 10, 35, 35, 10, 23, 10, 10, 10, 10, 10, 24, 28, 10, 35, 10, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 10, 35, 29, 10, 10, 10, 10, 10, 10, 10, 10, 10, 29, 10, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 29, 10, 10, 10, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, } + } + }; \ No newline at end of file diff --git a/DEMO.PAL b/DEMO.PAL new file mode 100644 index 0000000..2ebe242 Binary files /dev/null and b/DEMO.PAL differ diff --git a/DEMO.PCX b/DEMO.PCX new file mode 100644 index 0000000..637c28d Binary files /dev/null and b/DEMO.PCX differ diff --git a/DEMO.PRJ b/DEMO.PRJ new file mode 100644 index 0000000..6faa119 Binary files /dev/null and b/DEMO.PRJ differ diff --git a/DEMO1.PCX b/DEMO1.PCX new file mode 100644 index 0000000..02d9bde Binary files /dev/null and b/DEMO1.PCX differ diff --git a/FOTO.CPP b/FOTO.CPP new file mode 100644 index 0000000..c55ac1a --- /dev/null +++ b/FOTO.CPP @@ -0,0 +1,295 @@ + +#include +#include +#include + +#define OK 0 +#define ERROR 1 + +//#define RES_X 320 +//#define RES_Y 200 +#define RES_X 273+1 +#define RES_Y 411 + +typedef unsigned char DacPalette256[256][3]; +DacPalette256 Palette256; + +int CargaPaleta(char *file ); + +unsigned char Movs[73][71][3]; + +int MuestraImagen( char *file ); +void ProcesaPunto( int x, int y, char byte ); +void Mem2CPP(void); + FILE *out1,*out2,*out3,*out4; + +void main( int argc, char *argv[] ) +{ + int gd=DETECT, gm, errorcode; + int i, j, k; + +// initgraph( &gd, &gm, "c:\\program\\borlandc\\bgi" ); +errorcode = graphresult(); + +if (errorcode != grOk) /* an error occurred */ +{ + printf("Graphics error: %s\n", grapherrormsg(errorcode)); + printf("Press any key to halt:"); + getch(); + return; +} + if ( (out1=fopen("foto1.txt", "wt" ) ) != NULL ) + if ( (out2=fopen("foto2.txt", "wt" ) ) != NULL ) + if ( (out3=fopen("foto3.txt", "wt" ) ) != NULL ) + if ( (out4=fopen("foto4.txt", "wt" ) ) != NULL ) + { + + MuestraImagen( "D:\\JD2bin.pcx"/*argv[1]*/ ); +// CargaPaleta( argv[1] ); + fclose(out1); + fclose(out2); + fclose(out3); + fclose(out4); +// getch(); + } +// Mem2CPP(); + +// closegraph(); +} + +void Mem2CPP(void) +{ + FILE *out; + int i, j, k; + + if ( (out=fopen("foto.txt", "wt" ) ) != NULL ) + { + for ( i = 0; i < 411; i ++ ) + { + for ( j = 0; j < 273; j ++ ) + { + fprintf( out, "%d", (int)Movs[j][i][0] ); + } + fprintf( out, "\n" ); + } +/* + fprintf( out, "unsigned char Movs[23][23][3] = { \n"); + for ( k = 0; k < 3; k ++ ) + { + fprintf( out, " {\n"); + for ( i = 0; i < 22; i++ ) + { + fprintf( out, " { "); + for ( j = 0; j < 23; j++ ) + fprintf( out, "%03d, ", (int)Movs[j][i][k] ); + fprintf( out, " }, \n"); + } + i = 22; + fprintf( out, " { "); + for ( j = 0; j < 23; j++ ) + fprintf( out, "%03d, ", (int)Movs[j][i][k] ); + fprintf( out, " } \n"); + fprintf( out, " },\n"); + } + fprintf( out, " };"); + + fprintf( out, "\n\n\n"); + for ( i = 0; i < 256; i++ ) + fprintf ( out, "{ %03d, %03d, %03d }, \n", Palette256[i][0], Palette256[i][1], Palette256[i][2] ); +*/ + fclose(out); + } + + +} + + /**************************************************************************\ +|* *| +|* MuestraImagen *| +|* *| +|* Descripci¢n: *| +|* Descomprime y copia a la pagina indicada un PCX *| +|* *| +|* Entradas: nombre de la imagen *| +|* *| +|* *| +|* Salidas: OK Todo ha ido bien *| +|* ERROR Algo va mal *| +|* *| + \**************************************************************************/ +int MuestraImagen( char *file ) +{ + int alto, ancho, contador; + unsigned char byte; + FILE *fp; + + if ( (fp = fopen( file,"rb")) != NULL ) + { + // Saltamos la cabecera + fseek( fp, 128, SEEK_SET ); + + for(alto=0; alto0; contador--) + { +// set_point (ancho, alto, byte); +// ProcesaPunto( ancho, alto, byte ); +// fprintf( out, "%d", (int)byte ); +// fprintf( out, "%d", (int)byte == 0 ? 0: 1 ); + if ( alto <= RES_Y/2 ) + { + if ( ancho < RES_X/2 ) + { + gotoxy( 1,1 );cprintf( " " ); + + fprintf( out1, "%d", (int)byte == 0 ? 0: 1 ); + } else { + gotoxy( 1,1 );cprintf( "*" ); + + fprintf( out2, "%d", (int)byte == 0 ? 0: 1 ); + } + } else { + if ( ancho < RES_X/2 ) + { + gotoxy( 1,1 );cprintf( " " ); + + fprintf( out3, "%d", (int)byte == 0 ? 0: 1 ); + }else{ + gotoxy( 1,1 );cprintf( "*" ); + + fprintf( out4, "%d", (int)byte == 0 ? 0: 1 ); + } + } + + if ( alto <= RES_Y/2 ) + { + if ( ancho == RES_X/2 ) + fprintf( out1, "\n" ); + else if ( ancho == RES_X - 1 ) + fprintf( out2, "\n" ); + } else { + if ( ancho == RES_X/2 ) + fprintf( out3, "\n" ); + else if ( ancho == RES_X-1 ) + fprintf( out4, "\n" ); + } + ancho++; + } + } + + } + } + fclose(fp); + } else return ERROR; + + return OK; +} + + /**************************************************************************\ +|* *| +|* CargaPaleta *| +|* *| +|* Descripci¢n: *| +|* Carga la paleta con los colores por defecto *| +|* *| +|* *| +|* Entradas: achivo PCX de donde cargar la paleta *| +|* *| +|* Salidas: OK Todo ha ido bien *| +|* ERROR Algo va mal *| +|* *| + \**************************************************************************/ +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 + Palette256[index][0] = getc(fp) >> 2; + Palette256[index][1] = getc(fp) >> 2; + Palette256[index][2] = getc(fp) >> 2; + } // end for index + + } + + + fclose( fp ); + return OK; +} + +void ProcesaPunto( int x, int y, char byte ) +{ +/* + if ( x > 0 && x < 23 && y > 0 && y < 23 ) + Movs[x][y][0] = byte; + if ( x > 0 + 23 && x < 23 + 23 && y > 0 && y < 23 ) + Movs[x-23][y][1] = byte; + if ( x > 0 + 23*2 && x < 23 + 23*2 && y > 0 && y < 23 ) + Movs[x-23*2][y][2] = byte; +*/ + putpixel( x /*+ x*2*/, y /*+ y*2*/, byte ); +} diff --git a/FOTO.EXE b/FOTO.EXE new file mode 100644 index 0000000..d49451f Binary files /dev/null and b/FOTO.EXE differ diff --git a/FOTO1.TXT b/FOTO1.TXT new file mode 100644 index 0000000..e69de29 diff --git a/FOTO2.TXT b/FOTO2.TXT new file mode 100644 index 0000000..e69de29 diff --git a/FOTO3.TXT b/FOTO3.TXT new file mode 100644 index 0000000..e69de29 diff --git a/FOTO4.TXT b/FOTO4.TXT new file mode 100644 index 0000000..e69de29 diff --git a/MODEX.OBJ b/MODEX.OBJ new file mode 100644 index 0000000..ed817b0 Binary files /dev/null and b/MODEX.OBJ differ diff --git a/OUT.CPP b/OUT.CPP new file mode 100644 index 0000000..16dca97 --- /dev/null +++ b/OUT.CPP @@ -0,0 +1,335 @@ +unsigned char Movs[23][23][3] = { + { + { 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, }, + { 000, 200, 200, 200, 200, 200, 200, 200, 200, 010, 010, 010, 010, 010, 010, 200, 200, 200, 200, 010, 010, 200, 200, }, + { 000, 200, 200, 200, 200, 200, 200, 010, 010, 001, 011, 012, 012, 011, 011, 010, 200, 200, 010, 029, 035, 010, 200, }, + { 000, 200, 200, 200, 200, 200, 010, 011, 011, 012, 012, 012, 012, 012, 011, 011, 010, 010, 010, 035, 029, 010, 200, }, + { 000, 200, 200, 200, 200, 200, 010, 011, 012, 012, 012, 012, 012, 012, 012, 011, 011, 010, 200, 010, 010, 200, 200, }, + { 000, 200, 200, 200, 200, 010, 023, 024, 023, 024, 023, 011, 012, 012, 012, 012, 011, 010, 200, 200, 200, 200, 200, }, + { 000, 200, 200, 200, 200, 010, 024, 033, 010, 028, 028, 023, 011, 012, 012, 012, 012, 010, 200, 200, 200, 200, 200, }, + { 000, 200, 200, 200, 200, 010, 023, 028, 010, 028, 033, 024, 011, 012, 012, 012, 011, 010, 200, 200, 200, 200, 200, }, + { 000, 200, 200, 200, 200, 010, 024, 028, 010, 033, 028, 024, 011, 012, 012, 012, 011, 010, 200, 200, 200, 200, 200, }, + { 000, 200, 200, 200, 200, 010, 023, 024, 023, 024, 023, 011, 012, 012, 012, 011, 010, 010, 200, 200, 200, 200, 200, }, + { 000, 200, 200, 200, 200, 200, 010, 012, 012, 012, 010, 010, 010, 011, 011, 010, 010, 200, 200, 200, 200, 200, 200, }, + { 000, 200, 200, 200, 200, 200, 200, 010, 010, 010, 017, 028, 017, 010, 010, 010, 200, 200, 200, 200, 200, 200, 200, }, + { 000, 200, 200, 200, 200, 200, 010, 012, 018, 010, 028, 028, 028, 010, 011, 010, 200, 200, 200, 200, 200, 200, 200, }, + { 000, 200, 200, 200, 200, 200, 010, 012, 017, 010, 033, 028, 023, 010, 001, 010, 200, 200, 200, 200, 200, 200, 200, }, + { 000, 200, 200, 200, 200, 200, 010, 033, 028, 010, 010, 010, 010, 010, 010, 010, 200, 200, 200, 200, 200, 200, 200, }, + { 000, 200, 200, 200, 200, 200, 010, 012, 017, 010, 029, 035, 029, 010, 010, 010, 200, 200, 200, 200, 200, 200, 200, }, + { 000, 200, 200, 200, 200, 200, 200, 010, 010, 010, 010, 010, 010, 010, 010, 200, 200, 200, 200, 200, 200, 200, 200, }, + { 000, 200, 200, 200, 200, 200, 200, 200, 010, 028, 033, 028, 033, 028, 010, 200, 200, 200, 200, 200, 200, 200, 200, }, + { 000, 200, 200, 200, 200, 200, 200, 010, 010, 010, 010, 010, 010, 010, 010, 010, 200, 200, 200, 200, 200, 200, 200, }, + { 000, 200, 200, 200, 200, 010, 010, 010, 010, 035, 029, 035, 029, 010, 010, 010, 010, 010, 200, 200, 200, 200, 200, }, + { 000, 200, 200, 200, 010, 010, 010, 010, 010, 010, 010, 010, 010, 010, 010, 010, 010, 010, 010, 200, 200, 200, 200, }, + { 000, 200, 200, 200, 200, 010, 010, 010, 010, 010, 010, 010, 010, 010, 010, 010, 010, 010, 200, 200, 200, 200, 200, }, + { 000, 200, 200, 200, 200, 200, 200, 010, 010, 010, 010, 010, 010, 010, 010, 010, 200, 200, 200, 200, 200, 200, 200, } + }, + { + { 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, }, + { 000, 249, 200, 200, 200, 200, 200, 200, 200, 200, 010, 010, 010, 010, 010, 010, 200, 200, 200, 010, 010, 200, 200, }, + { 000, 249, 200, 200, 200, 200, 200, 200, 010, 010, 001, 011, 012, 012, 011, 011, 010, 200, 010, 035, 029, 010, 200, }, + { 000, 249, 200, 200, 200, 200, 200, 010, 011, 012, 012, 012, 012, 012, 012, 012, 011, 010, 010, 029, 035, 010, 200, }, + { 000, 249, 200, 200, 200, 200, 010, 011, 012, 012, 012, 012, 012, 012, 012, 012, 011, 010, 010, 010, 010, 200, 200, }, + { 000, 249, 200, 200, 200, 200, 010, 023, 024, 023, 011, 012, 012, 012, 012, 012, 012, 001, 010, 200, 200, 200, 200, }, + { 000, 249, 200, 200, 200, 200, 010, 024, 010, 028, 024, 011, 012, 012, 012, 012, 012, 011, 010, 200, 200, 200, 200, }, + { 000, 249, 200, 200, 200, 200, 010, 023, 010, 033, 024, 011, 012, 012, 012, 012, 012, 011, 010, 200, 200, 200, 200, }, + { 000, 249, 200, 200, 200, 200, 010, 024, 010, 028, 024, 011, 012, 012, 012, 012, 012, 011, 010, 200, 200, 200, 200, }, + { 000, 249, 200, 200, 200, 200, 010, 023, 024, 023, 011, 012, 012, 012, 012, 012, 011, 010, 010, 200, 200, 200, 200, }, + { 000, 249, 200, 200, 200, 010, 010, 010, 001, 011, 012, 012, 010, 010, 010, 011, 010, 010, 200, 200, 200, 200, 200, }, + { 000, 249, 200, 200, 010, 029, 035, 010, 010, 010, 010, 010, 028, 023, 018, 010, 010, 200, 200, 200, 200, 200, 200, }, + { 000, 249, 200, 200, 010, 035, 010, 010, 018, 024, 018, 010, 024, 028, 024, 018, 010, 010, 200, 200, 200, 200, 200, }, + { 000, 249, 200, 200, 200, 010, 028, 010, 018, 023, 018, 017, 010, 023, 028, 010, 035, 010, 200, 200, 200, 200, 200, }, + { 000, 249, 200, 200, 200, 010, 028, 010, 033, 028, 010, 010, 010, 010, 010, 035, 029, 010, 200, 200, 200, 200, 200, }, + { 000, 249, 200, 200, 200, 200, 010, 010, 018, 017, 018, 017, 018, 012, 010, 010, 010, 200, 200, 200, 200, 200, 200, }, + { 000, 249, 200, 200, 200, 200, 200, 010, 010, 028, 033, 024, 012, 012, 012, 010, 035, 010, 200, 200, 200, 200, 200, }, + { 000, 249, 200, 200, 200, 010, 010, 010, 028, 033, 024, 017, 010, 010, 010, 010, 035, 010, 200, 200, 200, 200, 200, }, + { 000, 249, 200, 200, 200, 010, 035, 035, 010, 024, 018, 010, 010, 028, 028, 010, 029, 010, 200, 200, 200, 200, 200, }, + { 000, 249, 200, 200, 200, 200, 010, 029, 035, 010, 010, 010, 010, 010, 010, 010, 010, 010, 010, 200, 200, 200, 200, }, + { 000, 249, 200, 200, 200, 010, 010, 010, 010, 010, 010, 010, 010, 010, 010, 010, 010, 010, 010, 010, 200, 200, 200, }, + { 000, 249, 200, 200, 200, 200, 010, 010, 010, 010, 010, 010, 010, 010, 010, 010, 010, 010, 010, 200, 200, 200, 200, }, + { 000, 249, 200, 200, 200, 200, 200, 200, 010, 010, 010, 010, 010, 010, 010, 010, 010, 200, 200, 200, 200, 200, 200, } + }, + { + { 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, }, + { 000, 200, 249, 200, 200, 200, 200, 200, 200, 200, 010, 010, 010, 010, 010, 010, 010, 200, 200, 010, 010, 200, 200, }, + { 000, 200, 249, 200, 200, 200, 200, 200, 200, 010, 001, 011, 012, 012, 012, 011, 011, 010, 010, 035, 035, 010, 200, }, + { 000, 200, 249, 200, 200, 200, 200, 200, 010, 011, 012, 012, 012, 012, 012, 012, 012, 011, 010, 035, 029, 010, 200, }, + { 000, 200, 249, 200, 200, 200, 200, 200, 010, 012, 012, 012, 012, 012, 012, 012, 012, 012, 011, 010, 010, 200, 200, }, + { 000, 200, 249, 200, 200, 200, 200, 010, 023, 024, 023, 024, 023, 024, 023, 011, 012, 012, 011, 010, 200, 200, 200, }, + { 000, 200, 249, 200, 200, 200, 200, 010, 010, 033, 028, 010, 028, 033, 028, 024, 011, 012, 011, 010, 200, 200, 200, }, + { 000, 200, 249, 200, 200, 200, 200, 010, 010, 028, 033, 010, 033, 028, 033, 024, 011, 012, 012, 010, 200, 200, 200, }, + { 000, 200, 249, 200, 200, 200, 200, 010, 010, 028, 028, 010, 028, 028, 028, 024, 011, 012, 011, 010, 200, 200, 200, }, + { 000, 200, 249, 200, 200, 200, 200, 010, 023, 024, 023, 024, 023, 024, 023, 011, 012, 012, 001, 010, 200, 200, 200, }, + { 000, 200, 249, 200, 200, 200, 200, 200, 010, 010, 018, 010, 010, 010, 001, 011, 012, 001, 010, 200, 200, 200, 200, }, + { 000, 200, 249, 200, 200, 200, 200, 010, 029, 035, 010, 010, 023, 018, 010, 010, 010, 010, 010, 200, 200, 200, 200, }, + { 000, 200, 249, 200, 200, 200, 200, 010, 035, 010, 024, 033, 028, 024, 010, 024, 012, 010, 018, 010, 200, 200, 200, }, + { 000, 200, 249, 200, 200, 200, 200, 010, 010, 024, 033, 028, 023, 018, 010, 024, 012, 010, 017, 018, 010, 200, 200, }, + { 000, 200, 249, 200, 200, 200, 200, 200, 010, 010, 028, 024, 018, 010, 010, 010, 010, 010, 010, 010, 010, 200, 200, }, + { 000, 200, 249, 200, 200, 200, 200, 200, 010, 018, 010, 010, 010, 018, 017, 018, 017, 010, 010, 035, 010, 200, 200, }, + { 000, 200, 249, 200, 200, 200, 010, 010, 018, 028, 018, 017, 018, 018, 012, 033, 024, 010, 010, 010, 200, 200, 200, }, + { 000, 200, 249, 200, 200, 010, 029, 010, 033, 028, 023, 010, 010, 010, 023, 028, 033, 024, 010, 200, 200, 200, 200, }, + { 000, 200, 249, 200, 200, 010, 035, 035, 010, 023, 010, 010, 010, 010, 010, 024, 028, 010, 035, 010, 200, 200, 200, }, + { 000, 200, 249, 200, 200, 200, 010, 035, 029, 010, 010, 010, 010, 010, 010, 010, 010, 010, 029, 010, 200, 200, 200, }, + { 000, 200, 249, 200, 200, 200, 010, 010, 010, 010, 010, 010, 010, 010, 010, 010, 010, 029, 010, 010, 010, 200, 200, }, + { 000, 200, 249, 200, 200, 200, 200, 010, 010, 010, 010, 010, 010, 010, 010, 010, 010, 010, 010, 010, 200, 200, 200, }, + { 000, 200, 249, 200, 200, 200, 200, 200, 200, 010, 010, 010, 010, 010, 010, 010, 010, 010, 200, 200, 200, 200, 200, } + }, + }; + + +{ 000, 000, 000 }, +{ 032, 000, 000 }, +{ 000, 032, 000 }, +{ 032, 032, 000 }, +{ 000, 000, 032 }, +{ 032, 000, 032 }, +{ 000, 032, 032 }, +{ 048, 048, 048 }, +{ 048, 055, 048 }, +{ 041, 050, 060 }, +{ 000, 000, 000 }, +{ 042, 000, 000 }, +{ 053, 000, 000 }, +{ 000, 010, 000 }, +{ 021, 010, 000 }, +{ 032, 010, 000 }, +{ 042, 010, 000 }, +{ 053, 010, 000 }, +{ 063, 010, 000 }, +{ 000, 021, 000 }, +{ 021, 021, 000 }, +{ 032, 021, 000 }, +{ 042, 021, 000 }, +{ 053, 021, 000 }, +{ 063, 021, 000 }, +{ 021, 032, 000 }, +{ 042, 032, 000 }, +{ 053, 032, 000 }, +{ 063, 032, 000 }, +{ 000, 042, 000 }, +{ 021, 042, 000 }, +{ 032, 042, 000 }, +{ 042, 042, 000 }, +{ 053, 042, 000 }, +{ 063, 042, 000 }, +{ 000, 053, 000 }, +{ 021, 053, 000 }, +{ 032, 053, 000 }, +{ 042, 053, 000 }, +{ 053, 053, 000 }, +{ 063, 053, 000 }, +{ 021, 063, 000 }, +{ 032, 063, 000 }, +{ 042, 063, 000 }, +{ 053, 063, 000 }, +{ 021, 000, 021 }, +{ 032, 000, 021 }, +{ 042, 000, 021 }, +{ 053, 000, 021 }, +{ 063, 000, 021 }, +{ 000, 010, 021 }, +{ 021, 010, 021 }, +{ 032, 010, 021 }, +{ 042, 010, 021 }, +{ 053, 010, 021 }, +{ 063, 010, 021 }, +{ 000, 021, 021 }, +{ 021, 021, 021 }, +{ 032, 021, 021 }, +{ 042, 021, 021 }, +{ 053, 021, 021 }, +{ 063, 021, 021 }, +{ 000, 032, 021 }, +{ 021, 032, 021 }, +{ 032, 032, 021 }, +{ 042, 032, 021 }, +{ 053, 032, 021 }, +{ 063, 032, 021 }, +{ 000, 042, 021 }, +{ 021, 042, 021 }, +{ 032, 042, 021 }, +{ 042, 042, 021 }, +{ 053, 042, 021 }, +{ 063, 042, 021 }, +{ 000, 053, 021 }, +{ 021, 053, 021 }, +{ 032, 053, 021 }, +{ 042, 053, 021 }, +{ 053, 053, 021 }, +{ 063, 053, 021 }, +{ 000, 063, 021 }, +{ 021, 063, 021 }, +{ 032, 063, 021 }, +{ 042, 063, 021 }, +{ 053, 063, 021 }, +{ 063, 063, 021 }, +{ 021, 000, 032 }, +{ 042, 000, 032 }, +{ 053, 000, 032 }, +{ 063, 000, 032 }, +{ 000, 010, 032 }, +{ 021, 010, 032 }, +{ 032, 010, 032 }, +{ 042, 010, 032 }, +{ 053, 010, 032 }, +{ 063, 010, 032 }, +{ 000, 021, 032 }, +{ 021, 021, 032 }, +{ 032, 021, 032 }, +{ 042, 021, 032 }, +{ 053, 021, 032 }, +{ 063, 021, 032 }, +{ 021, 032, 032 }, +{ 042, 032, 032 }, +{ 053, 032, 032 }, +{ 063, 032, 032 }, +{ 000, 042, 032 }, +{ 021, 042, 032 }, +{ 032, 042, 032 }, +{ 042, 042, 032 }, +{ 053, 042, 032 }, +{ 063, 042, 032 }, +{ 000, 053, 032 }, +{ 021, 053, 032 }, +{ 032, 053, 032 }, +{ 042, 053, 032 }, +{ 053, 053, 032 }, +{ 063, 053, 032 }, +{ 000, 063, 032 }, +{ 021, 063, 032 }, +{ 032, 063, 032 }, +{ 042, 063, 032 }, +{ 053, 063, 032 }, +{ 063, 063, 032 }, +{ 000, 000, 042 }, +{ 021, 000, 042 }, +{ 032, 000, 042 }, +{ 042, 000, 042 }, +{ 053, 000, 042 }, +{ 063, 000, 042 }, +{ 000, 010, 042 }, +{ 021, 010, 042 }, +{ 032, 010, 042 }, +{ 042, 010, 042 }, +{ 053, 010, 042 }, +{ 063, 010, 042 }, +{ 000, 021, 042 }, +{ 021, 021, 042 }, +{ 032, 021, 042 }, +{ 042, 021, 042 }, +{ 053, 021, 042 }, +{ 063, 021, 042 }, +{ 000, 032, 042 }, +{ 021, 032, 042 }, +{ 032, 032, 042 }, +{ 042, 032, 042 }, +{ 053, 032, 042 }, +{ 063, 032, 042 }, +{ 000, 042, 042 }, +{ 021, 042, 042 }, +{ 032, 042, 042 }, +{ 042, 042, 042 }, +{ 053, 042, 042 }, +{ 063, 042, 042 }, +{ 000, 053, 042 }, +{ 021, 053, 042 }, +{ 032, 053, 042 }, +{ 042, 053, 042 }, +{ 053, 053, 042 }, +{ 063, 053, 042 }, +{ 000, 063, 042 }, +{ 021, 063, 042 }, +{ 032, 063, 042 }, +{ 042, 063, 042 }, +{ 053, 063, 042 }, +{ 063, 063, 042 }, +{ 000, 000, 053 }, +{ 021, 000, 053 }, +{ 032, 000, 053 }, +{ 042, 000, 053 }, +{ 053, 000, 053 }, +{ 063, 000, 053 }, +{ 000, 010, 053 }, +{ 021, 010, 053 }, +{ 032, 010, 053 }, +{ 042, 010, 053 }, +{ 053, 010, 053 }, +{ 063, 010, 053 }, +{ 000, 021, 053 }, +{ 021, 021, 053 }, +{ 032, 021, 053 }, +{ 042, 021, 053 }, +{ 053, 021, 053 }, +{ 063, 021, 053 }, +{ 000, 032, 053 }, +{ 021, 032, 053 }, +{ 032, 032, 053 }, +{ 042, 032, 053 }, +{ 053, 032, 053 }, +{ 063, 032, 053 }, +{ 000, 042, 053 }, +{ 021, 042, 053 }, +{ 032, 042, 053 }, +{ 042, 042, 053 }, +{ 053, 042, 053 }, +{ 063, 042, 053 }, +{ 000, 053, 053 }, +{ 021, 053, 053 }, +{ 032, 053, 053 }, +{ 042, 053, 053 }, +{ 053, 053, 053 }, +{ 063, 053, 053 }, +{ 000, 063, 053 }, +{ 021, 063, 053 }, +{ 032, 063, 053 }, +{ 042, 063, 053 }, +{ 053, 063, 053 }, +{ 063, 063, 053 }, +{ 021, 000, 063 }, +{ 032, 000, 063 }, +{ 042, 000, 063 }, +{ 053, 000, 063 }, +{ 000, 010, 063 }, +{ 021, 010, 063 }, +{ 032, 010, 063 }, +{ 042, 010, 063 }, +{ 053, 010, 063 }, +{ 063, 010, 063 }, +{ 000, 021, 063 }, +{ 021, 021, 063 }, +{ 032, 021, 063 }, +{ 042, 021, 063 }, +{ 053, 021, 063 }, +{ 063, 021, 063 }, +{ 000, 032, 063 }, +{ 021, 032, 063 }, +{ 032, 032, 063 }, +{ 042, 032, 063 }, +{ 053, 032, 063 }, +{ 063, 032, 063 }, +{ 000, 042, 063 }, +{ 021, 042, 063 }, +{ 032, 042, 063 }, +{ 042, 042, 063 }, +{ 053, 042, 063 }, +{ 063, 042, 063 }, +{ 000, 053, 063 }, +{ 021, 053, 063 }, +{ 032, 053, 063 }, +{ 042, 053, 063 }, +{ 053, 053, 063 }, +{ 063, 053, 063 }, +{ 021, 063, 063 }, +{ 032, 063, 063 }, +{ 042, 063, 063 }, +{ 053, 063, 063 }, +{ 063, 062, 060 }, +{ 040, 040, 041 }, +{ 032, 032, 032 }, +{ 063, 000, 000 }, +{ 000, 063, 000 }, +{ 063, 063, 000 }, +{ 000, 000, 063 }, +{ 063, 000, 063 }, +{ 000, 063, 063 }, +{ 063, 063, 063 }, diff --git a/PAT0.PCX b/PAT0.PCX new file mode 100644 index 0000000..58695b1 Binary files /dev/null and b/PAT0.PCX differ diff --git a/PAT1.PCX b/PAT1.PCX new file mode 100644 index 0000000..84a37de Binary files /dev/null and b/PAT1.PCX differ diff --git a/PAT2.PCX b/PAT2.PCX new file mode 100644 index 0000000..36661fa Binary files /dev/null and b/PAT2.PCX differ diff --git a/PCX.CPP b/PCX.CPP new file mode 100644 index 0000000..e46c0e9 --- /dev/null +++ b/PCX.CPP @@ -0,0 +1,190 @@ +#include +#include +#include + +#define OK 0 +#define ERROR 1 + +//#define RES_X 320 +//#define RES_Y 200 +#define RES_X 73+1 +#define RES_Y 25 + +typedef unsigned char DacPalette256[256][3]; +DacPalette256 Palette256; + +int CargaPaleta(char *file ); + +unsigned char Movs[273][411][1]; + +int MuestraImagen( char *file ); +void ProcesaPunto( int x, int y, char byte ); +void Mem2CPP(void); + +void main( int argc, char *argv[] ) +{ + int gd=DETECT, gm; + + initgraph( &gd, &gm, "c:\\program\\borlandc\\bgi" ); + + MuestraImagen( argv[1] ); + CargaPaleta( argv[1] ); + getch(); + Mem2CPP(); + + closegraph(); +} + +void Mem2CPP(void) +{ + FILE *out; + int i, j, k; + + if ( (out=fopen("foto.txt", "wb" ) ) != NULL ) + { + for ( i = 0; i < 411; i ++ ) + { + for ( j = 0; j < 273; j ++ ) + { + fprintf( out, "%d", (int)Movs[j][i][0] ); + } + fprintf( out, "\n" ); + } +/* + fprintf( out, "unsigned char Movs[23][23][3] = { \n"); + for ( k = 0; k < 3; k ++ ) + { + fprintf( out, " {\n"); + for ( i = 0; i < 22; i++ ) + { + fprintf( out, " { "); + for ( j = 0; j < 23; j++ ) + fprintf( out, "%03d, ", (int)Movs[j][i][k] ); + fprintf( out, " }, \n"); + } + i = 22; + fprintf( out, " { "); + for ( j = 0; j < 23; j++ ) + fprintf( out, "%03d, ", (int)Movs[j][i][k] ); + fprintf( out, " } \n"); + fprintf( out, " },\n"); + } + fprintf( out, " };"); + + fprintf( out, "\n\n\n"); + for ( i = 0; i < 256; i++ ) + fprintf ( out, "{ %03d, %03d, %03d }, \n", Palette256[i][0], Palette256[i][1], Palette256[i][2] ); +*/ + fclose(out); + } + + +} + + /**************************************************************************\ +|* *| +|* MuestraImagen *| +|* *| +|* Descripci¢n: *| +|* Descomprime y copia a la pagina indicada un PCX *| +|* *| +|* Entradas: nombre de la imagen *| +|* *| +|* *| +|* Salidas: OK Todo ha ido bien *| +|* ERROR Algo va mal *| +|* *| + \**************************************************************************/ +int MuestraImagen( char *file ) +{ + int alto, ancho, contador; + unsigned char byte; + FILE *fp; + + if ( (fp = fopen( file,"rb")) != NULL ) + { + // Saltamos la cabecera + fseek( fp, 128, SEEK_SET ); + + for(alto=0; alto0; contador--) + { +// set_point (ancho, alto, byte); + ProcesaPunto( ancho, alto, byte ); + ancho++; + } + } + } + } + fclose(fp); + } else return ERROR; + + return OK; +} + + /**************************************************************************\ +|* *| +|* CargaPaleta *| +|* *| +|* Descripci¢n: *| +|* Carga la paleta con los colores por defecto *| +|* *| +|* *| +|* Entradas: achivo PCX de donde cargar la paleta *| +|* *| +|* Salidas: OK Todo ha ido bien *| +|* ERROR Algo va mal *| +|* *| + \**************************************************************************/ +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 + Palette256[index][0] = getc(fp) >> 2; + Palette256[index][1] = getc(fp) >> 2; + Palette256[index][2] = getc(fp) >> 2; + } // end for index + + } + + + fclose( fp ); + return OK; +} + +void ProcesaPunto( int x, int y, char byte ) +{ + Movs[x][y][0]=byte; +/* + if ( x > 0 && x < 23 && y > 0 && y < 23 ) + Movs[x][y][0] = byte; + if ( x > 0 + 23 && x < 23 + 23 && y > 0 && y < 23 ) + Movs[x-23][y][1] = byte; + if ( x > 0 + 23*2 && x < 23 + 23*2 && y > 0 && y < 23 ) + Movs[x-23*2][y][2] = byte; +*/ + putpixel( x /*+ x*2*/, y /*+ y*2*/, byte ); +} diff --git a/PCX.EXE b/PCX.EXE new file mode 100644 index 0000000..0017c15 Binary files /dev/null and b/PCX.EXE differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..bc63551 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +#DEMO +*09/03/1997* +ToDo: wwtcf? +![screenshot](/DEMO.png "Screenshot")