commit 255bc1b3721b1f988ead8232f2e370516b5f8aaa Author: jdg Date: Wed Sep 8 21:04:26 2021 +0200 First commit 11/11/1991 diff --git a/EGAVGA.BGI b/EGAVGA.BGI new file mode 100644 index 0000000..8001631 Binary files /dev/null and b/EGAVGA.BGI differ diff --git a/EPROM-II.CPP b/EPROM-II.CPP new file mode 100644 index 0000000..1ce24c3 --- /dev/null +++ b/EPROM-II.CPP @@ -0,0 +1,2118 @@ +/////////////////////// +/// JD. /// +/// /// +/// FuTuRe ViSiOn /// +////////////////////////////////////////////////////////////////////////////// +/// Nombre: Eprom-II.CPP /// +/// Modulo: Principal /// +/// Descripcin: Programador de Eprom's con ampliacin del numero /// +/// disponible de las mismas sin necesidad de /// +/// recompilar nada. /// +/// /// +/// Autor: Jos David Guilln Dominguez /// +/// Fecha: XX - XX - 1995 /// +/// /// +/// Comentario: -- Primera utilizacin de mi libreria ( v. BETA ) /// +/// con proposito de aplicacin final. /// +/// /// +/// Compilador Borland C++ 3.0 /// +////////////////////////////////////////////////////////////////////////////// + + + +// Librerias +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "..\..\jd_lib\make_bot.h" // Fuciones de MAKE_BOTON +#include "EPROM-ii.h" + +// Main +// +// ( Sin comentario ) +// + +int main(void){ + + if( carga_botones("Eprom.JDf") != 1 ) // Carga botones del fichero "botones.p1" + return 1; + + FILE *fichero; + + if( Lee_Eproms(fichero) != 1 ) // Carga las Eproms disponibles. + return 1; + + InicializaPc(); // No tengo ni idea de lo que estaba + // inicializando aqui. + // Ya lo he mirado: + // Inicializo los Campos... + + Initialize( 9, 2 ); // Inicializa el Modo Grfico + Menu_de_Edicion(); // Inicializa la Edicin + +farfree(S_Eprom); // Liberamos la memoria de los +restorecrtmode(); // distintos tipos de Eprom. +return 0; + +} + +// Menu de Edicion +// +// Editar y llevar el control de los ficheros para Eprom +// + +void Menu_de_Edicion(void){ + + CurrRowEprom1 = 1; CurrColEprom1 = 3; + CurrTopLineEprom = 1; + + int ok = 0; + + Imprime_Estaticos( 1, "Eprom.JDf" ); // Imprime botones estaticos 'Seccion 1' + Imprime_Secuencia(1); // Imprime secuencia 1. + Imprime_Estaticos( 2, "Eprom.JDf" ); // Imprime Textos ( 1 ), secuencia 1 + + Imprime_Eprom_Actual(); + + + Fuente( 2, 6 ); + + Abre_Ficha_Eprom(); + PrintWholeScreenEprom(); + GetLineEprom(); + EditCursorEprom(0); + +do{ // Bucle infinito + + switch( Comprueba_Secuencia( 1 ) ) { // Iniciamos comprobacion + + case 0: // No se pulso ningun BOTON + while( kbhit() ) getch(); // Limpiamos posibles teclas en BUFFER + CompruebaLineasEprom(); + EditCursorEprom(0); + break; + + case -2: // No se pulso ningun BOTON + // pero hay una tecla disponible... + key = getch(); + if ( isprint(key) || isspace(key) ){ + EditCursorEprom(0); + if(key!=13) ungetch(key); + Edit_Item_Eprom(); + EditCursorEprom(0); + } + break; + case -1: // Hay una tecla especial en BUFFER + EditCursorEprom(1); + key = getch(); + switch( key ){ + // Flecha Arriba + case 72: + Mueve_Arriba_Eprom(); + break; + // Flecha Izquierda + case 75: + case 15: + CurrColEprom1--; + if ( CurrColEprom1<1 ) CurrColEprom1=4; + break; + // Flecha Derecha + case 77: + case 9: + CurrColEprom1++; + if ( CurrColEprom1>4 ) CurrColEprom1=1; + break; + // Flecha Abajo + case 80: + Mueve_Abajo_Eprom(); + break; + // Buscar F2 + case 60: + // BuscarEprom(); + break; + // Imprimir Compras F5 + case 63: + // Imprimir_Eprom(); + break; + // F9 --> AADIR + case 67: + case 82: + AddRecordEprom(); + Eprom1.Direccion = 0; + PutLineEprom(); + PrintWholeScreenEprom(); + GetLineEprom(); + EditCursorEprom(0); + break; + // F10 -> BORRAR + case 68: + case 83: + DeleteRecordEprom(); + break; + // INICIO + case 71: + CurrColEprom1 = 1; + break; + // FIN + case 79: + CurrColEprom1 = 4; + break; + // RePg + case 73: + // CurrRow = 1; + if( CurrTopLineEprom > /*28*/25 ) { CurrTopLineEprom -= /*28*/25; } else { CurrTopLineEprom = 1; } + if( CurrTopLineEprom < 1 ) { CurrTopLineEprom = 1; } + PrintWholeScreenEprom(); + GetLineEprom(); + EditCursorEprom(0); + break; + // AvPg + case 81: + // CurrRow = 1; + CurrTopLineEprom += /*28*/25; + if ( (CurrTopLineEprom+CurrRowEprom1) > Eprom1_inx.Fin) { CurrTopLineEprom = Eprom1_inx.Fin; CurrRowEprom1 = 1; } + if (CurrTopLineEprom==0) CurrTopLineEprom = 1; + PrintWholeScreenEprom(); + GetLineEprom(); + EditCursorEprom(0); + break; + default: + BEEP(); + break; + } + EditCursorEprom(0); + break; + // Escoger EPROM + case 1: + Escoge_Eprom(); + break; + // Direccin incial a continuar + case 2: + if ( Modifica_Direccion == 1 ){ + Modifica_Direccion = 0; + setcolor(0); + setfillstyle(SOLID_FILL, 0); + bar(617, 103, 628, 112); + }else{ + Modifica_Direccion = 1; + setcolor(4/*58*/); + setfillstyle(SOLID_FILL, 4/*58*/); + bar(617, 103, 628, 112); + } + break; + // Imprimir Datos de Eprom + case 3: + Imprimir_Eprom(0,0); + break; + // Cargar Fichero + case 4: + Salvar_Cargar(2); + break; + // Salvar Fichero + case 5: + Salvar_Cargar(1); + break; + // Leer Datos de Eprom + case 6: + break; + // Cargar Datos en Eprom + case 7: + break; + // Salir + case 8: + ok = 1; + break; + } + +}while(!ok); + +fclose(Eprom); + +} + + + + + + + + + + +// +// Inicializa las estructructuras +// internas de boton... +// ---------------------------------- +// Como las de *.JDF pero INTERNAS +// ---------------------------------- +// + +void InicializaPc(void){ + PC[0].up = 50; PC[0].down = 440; + PC[0].left = 10; PC[0].right = 122; + + PC[1].up = 50; PC[1].down = 440; + PC[1].left = 132; PC[1].right = 295; + + PC[2].up = 50; PC[2].down = 440; + PC[2].left = 315; PC[2].right = 398; + + PC[3].up = 50; PC[3].down = 440; + PC[3].left = 408; PC[3].right = 535; +} + +// +// CARGA LAS EPROM'S DEL DISCO... +// +// FORMATO *.DAT diseado por J.D. +// ---------------------------------- +// + +int Lee_Eproms(FILE *fichero) +{ + char ch, buffer[15]; + int temp_num, temp_b; + long numero; +/* int SiZe_BoToN = 0, inc_Botones = -1; */ + int EpromActual = 0; + + if ( (fichero=fopen("Eprom.Dat","r"))==NULL ) exit(1); + + + ch=fgetc(fichero); //Lee el primer caracter + while (ch!=EOF) { //Lee hasta fin de fichero + if (ch=='*') //Linea con comentario + while (ch!=EOL && ch!=EOF) ch=fgetc(fichero); + + if (ch=='N') { //Numero de secuencias + + numero=0; + ch=fgetc(fichero); + while (ch!=EOL && ch!=EOF) { + if (ch>='0' && ch<='9') numero=numero*10+ch-48; + ch=fgetc(fichero); + } + N_Eprom = numero; + if ( (S_Eprom = (struct Eprom_Structura far *)farrealloc(S_Eprom, sizeof( struct Eprom_Structura )*N_Eprom )) == NULL) { + restorecrtmode(); + printf("\nNo Hay suficiente Memoria, para cargar los tipos de Eprom\n\n"); + exit (1); + } + + } + + if (ch=='%') { //Numero de Botones en la secuencia + numero=0; + ch=fgetc(fichero); + while (ch!=EOL && ch!=EOF && ch!=',') { + if (ch>='0' && ch<='9') numero=numero*10+ch-48; + ch=fgetc(fichero); + } + S_Eprom[EpromActual].TP = numero; + + numero=0; + ch=fgetc(fichero); + while (ch!=EOL && ch!=EOF && ch!=',') { + if (ch>='0' && ch<='9') numero=numero*10+ch-48; + ch=fgetc(fichero); + } + S_Eprom[EpromActual].FI = numero; + + numero=0; + ch=fgetc(fichero); + while (ch!=EOL && ch!=EOF && ch!=',') { + if (ch>='0' && ch<='9') numero=numero*10+ch-48; + ch=fgetc(fichero); + } + S_Eprom[EpromActual].NP = numero; + + numero=0; + ch=fgetc(fichero); + while (ch!=EOL && ch!=EOF && ch!=',') { + if (ch>='0' && ch<='9') numero=numero*10+ch-48; + ch=fgetc(fichero); + } + S_Eprom[EpromActual].DM = numero; + + numero=0; + ch=fgetc(fichero); + while (ch!=EOL && ch!=EOF && ch!=',') { + if (ch>='0' && ch<='9') numero=numero*10+ch-48; + ch=fgetc(fichero); + } + S_Eprom[EpromActual].BD = numero; + + numero=0; + ch=fgetc(fichero); + while (ch!=EOL && ch!=EOF && ch!=',') { + if (ch>='0' && ch<='9') numero=numero*10+ch-48; + ch=fgetc(fichero); + } + S_Eprom[EpromActual].ID = numero; + + + numero=0; + ch=fgetc(fichero); + strcpy(buffer, "\0"); + while (ch!=EOL && ch!=EOF && ch!='.' && (numero+1)<12+1) { + + ch=fgetc(fichero); + if(ch!='.') { buffer[numero] = ch; + numero++; + } + } + buffer[numero] = '\0'; + _fstrcpy(S_Eprom[EpromActual].ID_TEXT, (char near *)buffer); + + EpromActual++; + + } + + if (ch!=EOF) ch=fgetc(fichero); + } + + return OK; +} + +void BEEP(void){ + + sound(440); + delay(50); + nosound(); + +} + +//////// Funcion diseada para la introducion lineal de caracteres Grficos +//////// para el programa CATALOGO 4.0, por Jos David Guilln + +int InputCadenaG_l(char *s, int numalp, int lmax, int cc, int cf, struct boton Campo, int RoW) +{ + + char buf[81]; // Buffer de linea + int ls; // longitud cadena + char *s1; // puntero a cadena inicial + int i, c, ok; + + s1 = s; // inicio cadena + + setcolor(cf); // pone color a 0 para borrar + setfillstyle(SOLID_FILL, cf); + bar(Campo.left+4, Campo.up+5+RoW*15, Campo.right-4, Campo.up+4+RoW*15 + 16); + + + setcolor(cc); // devuelve el color a su estado + + outtextxy( Campo.left+4, Campo.up+/*3*/3+RoW*/*9*//*14*/15, s ); + + ls = strlen ( s ); // Longitud de actual + + if ( ls < lmax ) { + setcolor(4); + outtextxy( Campo.left+4+textwidth( s1 ), Campo.up+3+RoW*/*9*//*14*/15, ""); + } + + s += ls; // se coloca en el final + + do{ + c = getch(); // obtiene tecla + + ok = ( c == 13 || c == 0); // 13 = INTRO || Especiales + + if ( c == 8 && ls > 0 && !ok ) { // 8 = Back Space + ls--; + s--; + + *s = '\0'; + + setcolor(cf); + setfillstyle(SOLID_FILL, cf); + bar(Campo.left+4, Campo.up+5+RoW*15, Campo.right-4, Campo.up+4+RoW*15 + 16); + setcolor(cc); + outtextxy( Campo.left+4, Campo.up+3+RoW*/*9*//*14*/15, s1 ); + setcolor(4); + outtextxy( Campo.left+4+textwidth( s1 ), Campo.up+/*3*/2+RoW*/*9*//*14*/15, ""); + setcolor(cc); + + } else { + if ( !numalp && c >= 32 && c <= 254 /* isprint(c) */ && ls < lmax) { + + *s++ = c; + ls++; + + *s = '\0'; + setcolor(cf); + setfillstyle(SOLID_FILL, cf); + bar(Campo.left+4, Campo.up+5+RoW*15, Campo.right-4, Campo.up+4+RoW*/*9*//*14*/15 + /*9*/16); + setcolor(cc); + outtextxy( Campo.left+4, Campo.up+3+RoW*/*9*//*14*/15, s1 ); + + if ( ls < lmax ) { + setcolor(4); + outtextxy( Campo.left+4+textwidth( s1 ), Campo.up+3+RoW*/*9*//*14*/15, ""); + setcolor(cc); + } + + + } else { + if ( numalp && isdigit(c) && ls < lmax) { + *s++ = c; + ls++; + + *s = '\0'; // Cero final + setcolor(cf); + setfillstyle(SOLID_FILL, cf); + bar(Campo.left+4, Campo.up+5+RoW*15, Campo.right-4, Campo.up+4+RoW*/*9*//*14*/15 + /*9*/16); + setcolor(cc); + + outtextxy( Campo.left+4, Campo.up+3+RoW*/*9*//*14*/15, s1 ); + + if ( ls < lmax ) { + setcolor(4); + outtextxy( Campo.left+4+textwidth( s1 ), Campo.up+3+RoW*/*9*//*14*/15, ""); + setcolor(cc); + } + + + } else BEEP(); + } + } + + }while(!ok); + + ok = 1; + *s = ' '; + while( ok ) { + if(*s==' ') { *s = '\0'; s--; + } else { s++; ok = 0; } + } + + *s = '\0'; + + while(kbhit()) getch(); // Vacia Buffer impidiendo falsas + // pulsaciones... + + return ls; +} +//////// Funcion diseada para la introducion lineal de caracteres Grficos +//////// para el programa CATALOGO 4.0, por Jos David Guilln +//////// readactada para la introducion dependiente de la fuente en el +//////// programa EPROM_II. + +int InputCadenaG_l2(char *s, int numalp, int lmax, int cc, int cf, struct boton Campo, int RoW) +{ + + char buf[81]; // Buffer de linea + int ls; // longitud cadena + char *s1; // puntero a cadena inicial + int i, c, ok; + + s1 = s; // inicio cadena + + setcolor(cf); // pone color a 0 para borrar + setfillstyle(SOLID_FILL, cf); + + bar(Campo.left+3, Campo.up+3+(RoW-1)*10+2, Campo.right-3, Campo.up+3+(RoW-1)*10/*14*//*15*/ + /*9*/10); + + setcolor(cc); // devuelve el color a su estado + + outtextxy( Campo.left+4, Campo.up+2+(RoW-1)*10, s ); + + ls = strlen ( s ); // Longitud de actual + + if ( ls < lmax ) { + setcolor(4); + outtextxy( Campo.left+4, Campo.up+/*3*/2+(RoW-1)*10/*14*//*15*/, s1 ); + } + + s += ls; // se coloca en el final + + do{ + c = getch(); // obtiene tecla + + ok = ( c == 13 || c == 0); // 13 = INTRO || Especiales + + if ( c == 8 && ls > 0 && !ok ) { // 8 = Back Space + ls--; + s--; + + *s = '\0'; + + setcolor(cf); + setfillstyle(SOLID_FILL, cf); +// bar(Campo.left+3, Campo.up+3+(RoW-1)*12/*14*//*12*/+2, Campo.right-3, Campo.up+3+(RoW-1)*10/*14*//*15*/ + /*9*/10); + bar(Campo.left+3, Campo.up+3+(RoW-1)*10+2, Campo.right-3, Campo.up+3+(RoW-1)*10/*14*//*15*/ + /*9*/10); + setcolor(cc); + outtextxy( Campo.left+4, Campo.up+/*3*/2+(RoW-1)*10/*14*//*15*/, s1 ); + setcolor(4); + outtextxy( Campo.left+4+textwidth( s1 ), Campo.up+/*3*/2+(RoW-1)*/*9*//*14*/10, ""); + setcolor(cc); + + } else { + if ( !numalp && c >= 32 && c <= 254 /* isprint(c) */ && ls < lmax) { + + *s++ = c; + ls++; + + *s = '\0'; + setcolor(cf); + setfillstyle(SOLID_FILL, cf); + bar(Campo.left+3, Campo.up+3+(RoW-1)*10+2, Campo.right-3, Campo.up+3+(RoW-1)*10/*14*//*15*/ + /*9*/10); +// bar(Campo.left+3, Campo.up+3+(RoW-1)*12/*14*//*15*/+2, Campo.right-3, Campo.up+3+(RoW-1)*10/*14*//*15*/ + /*9*/10); + setcolor(cc); + outtextxy( Campo.left+4, Campo.up+/*3*/2+(RoW-1)*10/*14*//*15*/, s1 ); + + if ( ls < lmax ) { + setcolor(4); +// outtextxy( Campo.left+2, Campo.up+/*3*/2+(RoW-1)*12/*14*//*15*/, s ); + outtextxy( Campo.left+4+textwidth( s1 ), Campo.up+/*3*/2+(RoW-1)*/*9*//*14*/10, ""); + setcolor(cc); + } + + + } else { + if ( numalp && isdigit(c) && ls < lmax) { + *s++ = c; + ls++; + + *s = '\0'; // Cero final + setcolor(cf); + setfillstyle(SOLID_FILL, cf); +// bar(Campo.left+3, Campo.up+3+(RoW-1)*10/*14*//*15*/+2, Campo.right-3, Campo.up+3+(RoW-1)*10/*14*//*15*/ + /*9*/10); + bar(Campo.left+3, Campo.up+3+(RoW-1)*10+2, Campo.right-3, Campo.up+3+(RoW-1)*10/*14*//*15*/ + /*9*/10); +// bar(Campo.left+2, Campo.up+3+RoW*/*9*/14+2, Campo.right-2, Campo.up+3+RoW*/*9*/14 + /*9*/16); + setcolor(cc); + outtextxy( Campo.left+4, Campo.up+/*3*/2+(RoW-1)*10/*14*//*15*/, s1 ); +// outtextxy( Campo.left+2, Campo.up+/*3*/2+RoW*/*9*//*14*/15, s1 ); + + if ( ls < lmax ) { + setcolor(4); + outtextxy( Campo.left+4, Campo.up+/*3*/2+(RoW-1)*10/*14*//*15*/, s1 ); +// outtextxy( Campo.left+2+textwidth( s1 ), Campo.up+/*3*/+RoW*/*9*//*14*/15, ""); + setcolor(cc); + } + + + } else BEEP(); + } + } + + }while(!ok); + + ok = 1; + *s = ' '; + while( ok ) { + if(*s==' ') { *s = '\0'; s--; + } else { s++; ok = 0; } + } + + *s = '\0'; + + while(kbhit()) getch(); // Vacia Buffer impidiendo falsas + // pulsaciones... + + return ls; +} + +// +// Imprime la Emprom dentro del Boton +// +void Imprime_Eprom_Actual(void){ + + setcolor(0); + setfillstyle(SOLID_FILL, 0); + bar(552, 42, 628, 53); + + Fuente( 2, 4 ); + setcolor(63); + outtextxy(555, 42, S_Eprom[CurrEprom].ID_TEXT); + +} + +// +// Cambia de Fuente y tamao +// + +void Fuente( int Font, int size){ + + /* select the registered font */ + settextstyle( Font, HORIZ_DIR, size); + settextjustify(LEFT_TEXT, RIGHT_TEXT); + +} + +// +// Escoge una de las eproms del Archivo +// E P R O M . D A T +// + +void Escoge_Eprom(void){ + +char buffer[80]; +int acabar = 0, key; +int CurrRowCE=1, CurrTopLineCE = 0; + + Imprime_Estaticos( 3, "Eprom.JDf" ); // Imprime Textos ( 1 ), secuencia 1 + +sprintf(buffer, " % 3d", N_Eprom); +setcolor(2); +outtextxy(175, 157, buffer); +setcolor(0); +outtextxy(176, 158, buffer); +setcolor(63); + + PrintEprom_CE_WholeScreen(CurrTopLineCE); + +do{ + EditCursorEprom_CE(0, CurrRowCE, CurrTopLineCE); + while(!kbhit()); + key = getch(); + if(key == 13 ) { CurrEprom = CurrRowCE + CurrTopLineCE - 1; acabar = 1; } + else + if(key == 0 ) { + EditCursorEprom_CE(1, CurrRowCE, CurrTopLineCE); + switch(getch()){ + // Flecha ARRIBA + case 72: + if( (CurrRowCE+CurrTopLineCE)!=1 ){ + if(CurrRowCE == 1) { CurrTopLineCE--; PrintEprom_CE_WholeScreen(CurrTopLineCE); } + else CurrRowCE--; + } + break; + // Flecha ABAJO + case 80: + if( (CurrRowCE+CurrTopLineCE) EPROM +// + +int Escribe_Eprom(void){ + +char buffer[80]; +struct Eprom_s *Eprom2; + + struct byte_de_long { unsigned char P3; unsigned char P2; + unsigned char P1; unsigned char P0; + }; + union lngchr{ long Numero; struct byte_de_long Byte; } Division; + ////////////////////////////// + // long --> FF FF FF FF --> 3 34 65 59 + // P0 P1 P2 P3 Dec.89 101 52 3 + ////////////////////////////// Hex.59 65 34 3 + +int TP, cont; + +if( (Eprom2 = (struct Eprom_s *)farmalloc( sizeof(struct Eprom_s) * 100 )) == NULL ) { + return Operacion_Fallida; +} + +//////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////// +//////// TP --> case, escoge la tension de la eprom actual a la que le +//////// corresponde un cdigo en Hex. a enviar a la placa. ( TP ) +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////// +switch( S_Eprom[CurrEprom].TP ){ + case 250: + TP = 0x1; + break; + case 215: + TP = 0x0; + break; + case 125: + TP = 0x4; + break; + default: + return Operacion_Fallida; // Si la tensin es incorrecta, no programa +} + + +cont = 0; +longitud = 0; +Carga_Cien_Elementos(Eprom2); + +for(int i=0; i100) { + cont=0; + Carga_Cien_Elementos(Eprom2); +} + +} + +// Termina operacion + outportb( 0x303, (0) ); +/* + char TP; char FI; char NP; + char DM; char BD; long ID; + char ID_TEXT[15]; + +}; + +struct Eprom_Structura far *S_Eprom; +*/ +// struct Eprom_s { long Direccion; long Dato; }; +return 1; + +} + +// +// Manda el programa de +// EPROM ---> DISCO +// + +int Leer_en_Eprom(void){ + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Eprom_inx); + int LSC = sizeof(struct Eprom_s); + + char buffer[80]; + struct Eprom_s *Eprom2; + + struct byte_de_long { unsigned char P3; unsigned char P2; + unsigned char P1; unsigned char P0; + }; + union lngchr{ long Numero; struct byte_de_long Byte; } Division; + ////////////////////////////// + // long --> FF FF FF FF --> 3 34 65 59 + // P0 P1 P2 P3 Dec.89 101 52 3 + ////////////////////////////// Hex.59 65 34 3 + + int TP, cont; + + +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +fclose(Eprom); // Cerramos el archivo para poder borrarlo +remove("Eprom_JD.TMP"); // Y lo borramos, para reiniciarlo | +Abre_Ficha_Eprom(); // <<<<---<<<---<<--<--------------- +////////////////////////////////////////////////////////////////////////////// + CurrRowEprom1 = 1; // Inicializamos todo, para asegurar total + CurrColEprom1 = 3; // capacidad de correccion de errores, sobre + CurrTopLineEprom = 1; // la marcha... +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +outport( 0x303, 0x19 ); + +for(int i=0; i< pow(2, ( (S_Eprom[CurrEprom].DM)) ); i++) { + + // Tension + outport( 0x303, TP ); + // Direccin + Division.Numero = Eprom2[cont].Direccion; + outportb( 0x300, Division.Byte.P1 ); + outportb( 0x301, Division.Byte.P0 ); + // Dato + Division.Numero = Eprom2[cont].Dato; + outportb( 0x302, Division.Byte.P0 ); + // Impulso + outportb( 0x303, (TP + 16) ); + + // + // Retardo_____----_____ + // + // Barra_de_estado(); + delay(S_Eprom[CurrEprom].FI); + // while( ( clock() - Retrazo ) / CLK_TCK) / 1000) <= 50 ); + + fseek(Eprom, (long)LSJ + LSI + ( LSC * i ), SEEK_SET); + fwrite(&Eprom1, LSC, 1, Eprom); + +} + + +// Termina operacion + outportb( 0x303, (1) ); + +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +PrintWholeScreenEprom(); // Imprimimos el contenido de la EPROM leida +GetLineEprom(); // Obtenemos la primera Linea +EditCursorEprom(0); // Y la marcamos... +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +return 1; // Todo ha ido bien... + +} + +// +// Carga 100 datos a memoria y los +// indexa a un puntero a la estructura.. +// + +void Carga_Cien_Elementos(struct Eprom_s *Datos){ + +int LSJ = sizeof(struct JD); +int LSI = sizeof(struct Eprom_inx); +int LSC = sizeof(struct Eprom_s); +int contador; + +contador = 0; + + do{ + fseek(Eprom, (long)LSJ + LSI + ( LSC * longitud ), SEEK_SET); + fread(&Datos[contador], LSC, 1, Eprom); + longitud++; + }while(contador<100 && longitud <= Eprom1_inx.Fin); + + +} + + + + + + +// +// Men SALVAR <---> CARGAR +// +void Salvar_Cargar(int S_C){ + + int ok = 0, open_file = 1, cont = 0; + int LSJ = sizeof(struct JD); + + + CurrRowFile=1; CurrTopFile = 0; + CurrColFile=1; CurrRowCom = 1; + + strcpy(Archivo, ArchivoDatos); + + PC[1].up =/*155*/153; PC[1].down = 170; + PC[1].left = 270; PC[1].right = 465; + + PC[2].up = 201; PC[2].down = 249; + PC[2].left = 270; PC[2].right = 465; + +//******* Salvar ---> 1 +//******* Cargar ---> 2 + + Imprime_Estaticos( 4, "Eprom.JDf" ); // Imprime botones estaticos 'Seccion 1' + + + Lee_Archivos_Presentes(S_C); + + setcolor(63); + + Fuente( 2, 4 ); + + + + PrintWholeScreenFile(); + CurrColFile=2; + EditCursorFile(1); + CurrColFile=3; +if(S_C==2) { + LeeCabecera(&Archivo_list[0]); +PrintWholeScreenCabecera(); +} else + PrintWholeScreenFile(); + CurrColFile=1; + EditCursorFile(0); + + +do{ // Bucle infinito + + switch( Comprueba_Secuencia( 2 ) ) { // Iniciamos comprobacion + + case 0: // No se pulso ningun BOTON + while( kbhit() ) getch(); // Limpiamos posibles teclas en BUFFER + break; + + case -2: // No se pulso ningun BOTON + // pero hay una tecla disponible... + key = getch(); + if ( isprint(key) || isspace(key) ){ + EditCursorFile(0); + if(CurrColFile == 1 ) { + strcpy(Archivo, &Archivo_list[13*(CurrRowFile + CurrTopFile - 1)] ); + cont = 0; + while( Archivo[cont] != '.' ) cont++; + Archivo[cont] = '\0'; + CurrColFile=2; + EditCursorFile(1); + CurrColFile=1; + } else { + if(key!=13) ungetch(key); + Edit_Item_File(); + } + + EditCursorFile(0); + } + break; + case -1: // Hay una tecla especial en BUFFER + EditCursorFile(1); + key = getch(); + switch( key ){ + // Flecha Arriba + case 72: + if(CurrColFile == 1) { + if( (CurrRowFile + CurrTopFile) != 1 ) + if(CurrRowFile == 1) { CurrTopFile--; PrintWholeScreenFile(); } + else CurrRowFile--; + if(S_C==2) { + LeeCabecera(&Archivo_list[13*(CurrRowFile + CurrTopFile - 1)]); + CurrColFile=3; + PrintWholeScreenCabecera(); + CurrColFile=1; } + + } else if(CurrColFile == 3) { + CurrRowCom--; + if(CurrRowCom<1) CurrRowCom = 4; + } + break; + // Flecha Izquierda + case 75: + case 15: + CurrColFile--; + if ( CurrColFile<1 ) CurrColFile=3; + break; + // Flecha Derecha + case 77: + case 9: + CurrColFile++; + if ( CurrColFile>3 ) CurrColFile=1; + break; + // Flecha Abajo + case 80: + if(CurrColFile == 1) { + if( (CurrRowFile + CurrTopFile) < N_Files ) + if(CurrRowFile == 12) { CurrTopFile++; PrintWholeScreenFile(); } + else CurrRowFile++; + if(S_C==2) { + LeeCabecera(&Archivo_list[13*(CurrRowFile + CurrTopFile - 1)]); + CurrColFile=3; + PrintWholeScreenCabecera(); + CurrColFile=1; } + + } else if(CurrColFile == 3) { + CurrRowCom++; + if(CurrRowCom>4) CurrRowCom = 1; + } + break; + } + EditCursorFile(0); + break; + // Aceptar + case 1: +// ******* Salvar ---> 1 +// ******* Cargar ---> 2 + if(S_C==1) { + if(open_file == 1){ + rewind(Eprom); + fwrite(&cabecera, LSJ, 1, Eprom); + fclose(Eprom); + open_file = 0; + } +// +// Copia el fichero *.TMP a *.PDE +// + strcat(Archivo, ".PDE"); + fcopy( "Eprom_JD.TMP", Archivo ); + + if ( Abre_Ficha_Eprom() == 1 ) { open_file = 1; ok = 1; } + + } else { + if(open_file == 1){ + fclose(Eprom); + open_file = 0; + } + if( strcmp( Archivo, " < NUEVO > ") == 0 ){ remove("Eprom_JD.TMP"); + CurrRowEprom1 = 1; + } else { + +// +// Copia el fichero *.PDE a *.TMP +// + strcat(Archivo, ".PDE"); + fcopy( Archivo, "Eprom_JD.TMP"); + } + + if ( Abre_Ficha_Eprom() == 1 ) ok = 1; + + } + break; + // Direccin incial a continuar + case 2: + if(open_file == 0 ){ // remove("Eprom_JD.TMP"); + CurrRowEprom1 = 1; + } + ok = 1; + break; + default: + BEEP(); + break; + } + +}while(!ok); + + free(Archivo_list); + + InicializaPc(); + Imprime_Estaticos( 2, "Eprom.JDf" ); // Imprime Textos ( 1 ), secuencia 1 + Imprime_Eprom_Actual(); + Fuente( 2, 6 ); + PrintWholeScreenEprom(); + GetLineEprom(); + EditCursorEprom(0); + +} + +// +// Busca en el disco, archivos con el +// formato *.PDE >>Programador de Eprom +// +void Lee_Archivos_Presentes(int add_new){ + +struct ffblk ffblk; +int done; + +N_Files=0; + +if(add_new==2) { + N_Files++; + if( ( Archivo_list = (char *)realloc( Archivo_list, ( (sizeof(char) )*N_Files ) ) ) == NULL) return; + strcpy( &Archivo_list[ 13*(N_Files - 1)], " < NUEVO > "); +}else { + N_Files++; + if( ( Archivo_list = (char *)realloc( Archivo_list, ( (sizeof(char) )*N_Files ) ) ) == NULL) return; + strcpy( &Archivo_list[ 13*(N_Files - 1)], ""); +} + + +done = findfirst("*.PDE",&ffblk,0); + +while (!done) + { + N_Files++; + if( (Archivo_list = (char *)realloc( Archivo_list, ((sizeof(char)*13)*N_Files) ) ) == NULL ) return; + if(done==0) strcpy( &Archivo_list[ 13*(N_Files - 1)], ffblk.ff_name); + done = findnext(&ffblk); + } + + +} + +// +// Imprime en Pantalla mientras quede +// datos en el DISCO, o Espacio en +// Pantalla.n Pantalla mientras quede +// + +void PrintWholeScreenFile(void){ + + +char buffer[80]; + +//int TP, FI, NP, DM, BD; +int CurrRowCE; + +if(CurrColFile==1) { + + setcolor(0); setfillstyle(SOLID_FILL, 0); + bar( 177, 177, 263, 323); + setcolor(63); + + for(CurrRowCE = 1; CurrRowCE < (12+1); CurrRowCE++) + + if ( (CurrTopFile + CurrRowCE ) <= N_Files ) { + + + sprintf(buffer, "%13s", &Archivo_list[13*(CurrTopFile + CurrRowCE - 1)] ); + outtextxy( 177, ( 178 + (CurrRowCE - 1)*10), buffer); + } +} else if(CurrColFile==3){ + + setcolor(0); setfillstyle(SOLID_FILL, 0); + bar( 272, 202, 463, 248); + setcolor(63); + + for(CurrRowCE = 1; CurrRowCE < (4+1); CurrRowCE++) { + + sprintf(buffer, "%s", cabecera.Comentario[(CurrRowCE-1)] ); + outtextxy( 275, ( 204 + (CurrRowCE - 1)*10), buffer); + } + +} + +} + +// +// Imprime en Pantalla mientras quede +// datos en el DISCO, o Espacio en +// Pantalla.n Pantalla mientras quede +// + +void PrintWholeScreenCabecera(void){ + + +char buffer[80]; + +//int TP, FI, NP, DM, BD; +int CurrRowCE; + + setcolor(0); setfillstyle(SOLID_FILL, 0); + bar( 272, 202, 463, 248); + setcolor(63); + + for(CurrRowCE = 1; CurrRowCE < (4+1); CurrRowCE++) { + + sprintf(buffer, "%s", cabecera2.Comentario[(CurrRowCE-1)] ); + outtextxy( 275, ( 204 + (CurrRowCE - 1)*10), buffer); + } + + +} + +// +// Realza los datos de EPROMS a ser +// editados cuando sean sealados por +// el cursor. +// + +void EditCursorFile(int SH){ + +char buffer[80]; + + if (!SH) { setcolor(63); setfillstyle(SOLID_FILL, 63); } + else + { setcolor(0); setfillstyle(SOLID_FILL, 0); } + +if(CurrColFile==1) { + + bar( 177, 178+ ( CurrRowFile-1 )*10 + 2, 263, 178 + ( CurrRowFile - 1 )*10+10 ); + + if(!SH) setcolor(0); else Texto_Normal + + sprintf(buffer, "%13s", &Archivo_list[13*(CurrTopFile + CurrRowFile - 1)] ); + outtextxy( 177, ( 178 + (CurrRowFile - 1)*10), buffer); +} else if(CurrColFile==2){ + + bar(272, 157, 463, 168); + + if(!SH) setcolor(0); else Texto_Normal +if(strlen(Archivo)<11) + sprintf(buffer, " %8s.PDE", Archivo ); +else + sprintf(buffer, " %13s", Archivo ); + outtextxy( 280, 156, buffer); +// & 155, 270, 465, 170, 0, 56, 63, 1, 2 +} else if(CurrColFile==3) { + + bar( 273, 204+ ( CurrRowCom-1 )*10 + 2, 462, 204 + ( CurrRowCom - 1 )*10+10 ); + + if(!SH) setcolor(0); else Texto_Normal + + sprintf(buffer, "%s", cabecera.Comentario[(CurrRowCom-1)] ); + outtextxy( 275, ( 204 + (CurrRowCom - 1)*10), buffer); + +} + + + +} + +// +// Edita el Dato seleccionado por el +// cursor, en carga y descarga de FILE +// + +void Edit_Item_File(void){ + + char buffer[80]; + +switch (CurrColFile) { + case 2: +// sprintf( buffer, "%s", Archivo); + InputCadenaG_l2( Archivo, 0, 8, 63, 57, PC[1], 1); + break; + case 3: +// sprintf( buffer, "%s", cabecera.Comentario[(CurrRowCom-1)]); + InputCadenaG_l2( cabecera.Comentario[(CurrRowCom-1)], 0, 30, 63, 57, PC[2], CurrRowCom); + break; + default: + return; + } + +} + + + + + + + + +// Abre_Ficha_Eprom +// +// Abre el archivo contenido en ArchivoDatos, y comprueba que sea +// del formato adecuado y la versin 1.1 +// + +int LeeCabecera(char *fichero){ + +//// +// Comprueba apertura correcta de Indice, y Datos y creacin... // +//// + + int LSJ = sizeof(struct JD); + fclose(EpromC); + + if ( (EpromC = fopen( fichero, "rb"))==NULL) { + + strcpy(cabecera2.Comentario[0], "\0"); + strcpy(cabecera2.Comentario[1], "Fichero no se puede abrir"); + strcpy(cabecera2.Comentario[2], "\0"); + strcpy(cabecera2.Comentario[3], "\0"); + return (-1); + + } + + if ( fread(&cabecera2, LSJ, 1, EpromC) != 1 ) { + restorecrtmode(); + printf("NO SE PUDO LEER EN EL FICHERO: INDICE, temporal"); + exit(1); + } + + if(cabecera2.esc != 27 || cabecera2.pt != 7 || cabecera2.ef != 26 ) { + strcpy(cabecera2.Comentario[0], "\0"); + strcpy(cabecera2.Comentario[1], "Fichero no compatible"); + strcpy(cabecera2.Comentario[2], "\0"); + strcpy(cabecera2.Comentario[3], "\0"); + return (-1); + // Cabecera no valida ((ERROR LEYENDO ESTRUCTURAS)) + } + + return 1; +} + + + +//// +// // +// // +// // +// // +// // +// // +//// + + // Mueve Abajo Eprom // + // // + // Realizar el Scroll Vertical hacia abajo y la gestin de la // + // rectificacin al paso. ( Direccin --> ON ) // + //// + +void Mueve_Abajo_Eprom(void){ + + int CurrRecord = CurrTopLineEprom + CurrRowEprom1 - 1; + int OldDir = Eprom1.Direccion; + + if (CurrRowEprom1==25) { + if ( (CurrRecord - 1) >= Eprom1_inx.Fin) { BEEP(); EditCursorEprom(0); } + else { + +// CurrTopLineEprom++; + CurrRowEprom1=1; + CurrTopLineEprom += /*28*/25; + if ( (CurrTopLineEprom+CurrRowEprom1) > Eprom1_inx.Fin) { CurrTopLineEprom = Eprom1_inx.Fin; CurrRowEprom1 = 1; } + if (CurrTopLineEprom==0) CurrTopLineEprom = 1; + if ( Modifica_Direccion == 1 ) { Eprom1.Direccion = OldDir+1; + PutLineEprom(); +// PrintLineEprom(); + } + PrintWholeScreenEprom(); + GetLineEprom(); + + + } + } else { + if( (CurrRecord - 1) >= Eprom1_inx.Fin) { BEEP(); EditCursorEprom(0); } + else { CurrRowEprom1++; + + GetLineEprom(); + if ( Modifica_Direccion == 1 ) { Eprom1.Direccion = OldDir+1; + PutLineEprom(); + PrintLineEprom(); + } + + } + } + +} + +// Mueve Arriba Eprom +// +// Realizar el Scroll Vertical hacia arriba y la gestin de la +// rectificacin al paso. ( Direccin --> ON ) +// + +void Mueve_Arriba_Eprom(void){ + int CurrRecord = CurrTopLineEprom + CurrRowEprom1 - 1; + int OldDir = Eprom1.Direccion; + + if (CurrRowEprom1==1) { + if ((CurrRecord - 1) <= 0) { BEEP(); EditCursorEprom(0); } + else { +// CurrTopLineEprom--; + CurrRowEprom1=25; + if( CurrTopLineEprom > /*28*/25 ) { CurrTopLineEprom -= /*28*/25; } else { CurrTopLineEprom = 1; } + if( CurrTopLineEprom < 1 ) { CurrTopLineEprom = 1; } + if ( Modifica_Direccion == 1 ) { Eprom1.Direccion = OldDir-1; + PutLineEprom(); +// PrintLineEprom(); + } + PrintWholeScreenEprom(); + GetLineEprom(); + } + + } else { + if( (CurrRecord - 1) <= 0) BEEP(); + else { CurrRowEprom1--; + GetLineEprom(); + if ( Modifica_Direccion == 1 ) { Eprom1.Direccion = OldDir-1; + PutLineEprom(); + PrintLineEprom(); + } + + } + } + +} + + +// EditCursorEprom +// +// Edita, (resalta o no), el cursor, (Barra situada sobre el campo) +// + +void EditCursorEprom(int ShowHide) { + + char Buffer[80]; + int x, x2, y = 50; + + setcolor(7); + setfillstyle(SOLID_FILL, 7); + bar(12, 457, 545, 470); + + if (!ShowHide) { setcolor(63); setfillstyle(SOLID_FILL, 63); } + else + { setcolor(0); setfillstyle(SOLID_FILL, 0); } + + switch( CurrColEprom1 ){ + case 1: x = 10; x2 = 122; break; + case 2: x = 132; x2 = 295; break; + case 3: x = 315; x2 = 398; break; + case 4: x = 408; x2 = 535; break; + default: break; + } + + bar( (x+4), y+2+(CurrRowEprom1-1)*15+4, x2-4, y+4+((CurrRowEprom1)-1)*15+16); + + + if(!ShowHide) setcolor(0); else Texto_Normal + + switch(CurrColEprom1){ + case 1: + sprintf(Buffer, "% 10lX", Eprom1.Direccion); + outtextxy( x+4, (y+2)+(CurrRowEprom1-1)*15, Buffer ); + outtextxy( 15, 455, "Direccin ( HEXADECIMAL ) "); + break; + case 2: + sprintf(Buffer, "% 15lu", Eprom1.Direccion); + outtextxy( x+4, (y+2)+(CurrRowEprom1-1)*15, Buffer ); + outtextxy( 15, 455, "Direccin ( DECIMAL ) "); + break; + case 3: + sprintf(Buffer, "% 7X", Eprom1.Dato); + outtextxy( x+4, (y+2)+(CurrRowEprom1-1)*15, Buffer ); + outtextxy( 15, 455, "Dato ( HEXADECIMAL ) "); + break; + case 4: + sprintf(Buffer, "% 12u", Eprom1.Dato); + outtextxy( x+4, (y+2)+(CurrRowEprom1-1)*15, Buffer ); + outtextxy( 15, 455, "Dato ( DECIMAL ) "); + break; + } + +} + + +// PrintLineEprom +// +// Imprime una linea con todos los datos de la Eprom. +// + +void PrintLineEprom(void){ + + char Buffer[80]; + int x, x2, y = 50; + setcolor(0); + setfillstyle(SOLID_FILL, 0); +for(int i=1; i<=4; i++){ + switch( i ){ + case 1: x = 10; x2 = 122; break; + case 2: x = 132; x2 = 295; break; + case 3: x = 315; x2 = 398; break; + case 4: x = 408; x2 = 535; break; + default: break; + } + bar( (x+4), y+2+(CurrRowEprom1-1)*15+2, x2-4, y+4+((CurrRowEprom1)-1)*15+16); +} + + Texto_Normal + + sprintf(Buffer, "% 10lX", Eprom1.Direccion); + + sprintf(Buffer, "% 10lX", Eprom1.Direccion); + outtextxy( 10+4, (y+2)+(CurrRowEprom1-1)*15, Buffer ); + sprintf(Buffer, "% 15lu", Eprom1.Direccion); + outtextxy(132+4, (y+2)+(CurrRowEprom1-1)*15, Buffer ); + sprintf(Buffer, "% 7X", Eprom1.Dato); + outtextxy(315+4, (y+2)+(CurrRowEprom1-1)*15, Buffer ); + sprintf(Buffer, "% 12u", Eprom1.Dato); + outtextxy(408+4, (y+2)+(CurrRowEprom1-1)*15, Buffer ); + +} + +// PrintWholeScreen +// +// Imprime Datos solo si caben en la pantalla de visualizacin. +// + +void PrintWholeScreenEprom(void){ + +int tmp = CurrRowEprom1; + +int x, x2, y=50, y2=440; + +setcolor(0); +setfillstyle(SOLID_FILL, 0); + +for(int i=1; i<=4; i++){ + switch( i ){ + case 1: x = 10; x2 = 122; break; + case 2: x = 132; x2 = 295; break; + case 3: x = 315; x2 = 398; break; + case 4: x = 408; x2 = 535; break; + default: break; + } bar( x+4, y+3, x2-4, y2-3); + +} + + + + for(CurrRowEprom1 = 1; CurrRowEprom1 < (/*28*/25+1); CurrRowEprom1++) + + if ( (CurrTopLineEprom + CurrRowEprom1 - 1) <= (Eprom1_inx.Fin + 1) ) { + GetLineEprom(); + PrintLineEprom(); + } + +CurrRowEprom1 = tmp; + +} + +// Edit_Item_Eprom +// +// Edita, el campo actual. (Modifica borrando lo anterior.) +// + +void Edit_Item_Eprom(void){ + + char buffer[80], *endptr; + long Fecha; + +struct Eprom_Structura { + + char TP; char FI; char NP; + long DM; char BD; long ID; + char ID_TEXT[15]; + +}; + + switch (CurrColEprom1) { + case 1: + // sprintf(buffer, "%lX", Eprom1.Direccion); + do{ + strcpy( buffer, "\0"); + InputCadenaG_l( buffer, 0, 6, 63, 57, PC[0], CurrRowEprom1-1); + Eprom1.Direccion = strtol(buffer, &endptr, 16); + }while(*endptr!=NULL || Eprom1.Direccion > pow(2, ( (S_Eprom[CurrEprom].DM)) ) ); + // pow(2, ( (S_Eprom[CurrEprom].DM)/8) ) + PutLineEprom(); + PrintLineEprom(); + break; + + case 2: // sprintf( buffer, "%lu", Eprom1.Direccion); + do{ + strcpy( buffer, "\0"); + InputCadenaG_l( buffer, 1, 9/*( ( (S_Eprom[CurrEprom].BD)/8) * 3)*/, 63, 57, PC[1], CurrRowEprom1-1); + Eprom1.Direccion = atol(buffer); + }while( Eprom1.Direccion > pow(2, ( (S_Eprom[CurrEprom].DM) ) ) ); + PutLineEprom(); + PrintLineEprom(); + break; + + case 3: + // sprintf( buffer, "%X", Eprom1.Dato); + strcpy( buffer, "\0"); + do{ + InputCadenaG_l( buffer, 0, ( ( (S_Eprom[CurrEprom].BD)/8) * 2), 63, 57, PC[2], CurrRowEprom1-1); + Eprom1.Dato = strtol(buffer, &endptr, 16); + }while(*endptr!=NULL || Eprom1.Dato > pow(2, S_Eprom[CurrEprom].BD ) ); + PutLineEprom(); + PrintLineEprom(); + if ( (CurrTopLineEprom + CurrRowEprom1 - 2) >= Eprom1_inx.Fin) + AddRecordEprom(); + else Mueve_Abajo_Eprom(); + break; + case 4: + sprintf( buffer, "%u", Eprom1.Dato); + { + strcpy( buffer, "\0"); + InputCadenaG_l( buffer, 1, ( ( (S_Eprom[CurrEprom].BD)/8) * 3), 63, 57, PC[3], CurrRowEprom1-1); + Eprom1.Dato = atoi(buffer); + }while(Eprom1.Dato > pow(2, S_Eprom[CurrEprom].BD )); + PutLineEprom(); + PrintLineEprom(); + if ( (CurrTopLineEprom + CurrRowEprom1 - 2) >= Eprom1_inx.Fin) + AddRecordEprom(); + else Mueve_Abajo_Eprom(); + break; + + default: + return; + } + + PrintLineEprom(); + +} + +// +// +// +// +// +// +// +// + + // Imprimir_Eprom // + // // + // Imprime el programa completo. // + //// + +void Imprimir_Eprom(int desde, int hasta){ + + +int LSJ = sizeof(struct JD); +int LSI = sizeof(struct Eprom_inx); +int LSC = sizeof(struct Eprom_s); + +int lprint = 3, Curr_Eprom = 0; + +if( Comprueba_Impresora()==0 ) return; + +fprintf( stdprn, "\n\r"); + + + fprintf( stdprn, " Direccion Dato \n\r"); + fprintf( stdprn, "\n\r"); + + while( (Curr_Eprom <= Eprom1_inx.Fin) ){ + + fseek(Eprom, (long)LSJ + LSI + ( LSC * Curr_Eprom ), SEEK_SET); // Se coloca + fread(&Eprom1, LSC, 1, Eprom); // Y lee + + fprintf( stdprn, " %10lX %15lu %7X %12u", + Eprom1.Direccion, Eprom1.Direccion, Eprom1.Dato, Eprom1.Dato); + + lprint++; + if (lprint==55) { lprint = 3; + fprintf( stdprn, " Direccion Dato \n\r"); + fprintf( stdprn, "\n\r"); + } + + Curr_Eprom++; + } + + + fprintf( stdprn, "\n\r"); + fprintf( stdprn, " Registrese y obtengan la ultima y mas novedosa versin del software y hardware."); + fprintf( stdprn, "\n\r"); + + fputc(12, stdprn); + + +} + +// +// Comprueba a nivel de BIOS si hay una +// impresora conectada en LPT1 -> DX = 0 +// + +int Comprueba_Impresora(void){ + + unsigned int tmp; + union REGS Impresora_in, Impresora_out; + struct byte { + int a : 1; + int b : 1; + int c : 1; + int d : 1; + int e : 1; + int f : 1; + int g : 1; + int h : 1; + }; + union bits { + char ch; + struct byte bit; + } Imp_out; + + Impresora_in.h.ah = 0x02; + Impresora_in.x.dx = 0x0; + + int86(0x17, &Impresora_in, &Impresora_out); + + return ( Impresora_out.h.ah ? 1 : 0 ); + +} + +// +// +// +// +// +// +// +// + +// Abre_Ficha_Eprom +// +// Abre el archivo contenido en ArchivoDatos, y comprueba que sea +// del formato adecuado y la versin 1.1 +// + +int Abre_Ficha_Eprom(void){ + +CurrRowEprom1 = 1; +CurrTopLineEprom = 1; + +//// +// Comprueba apertura correcta de Indice, y Datos y creacin... // +//// + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Eprom_inx); + int LSC = sizeof(struct Eprom_s); + + if ( (Eprom = fopen( ArchivoDatos, "r+b"))==NULL) { + + FILE *fa; int i; + + if ( (fa = fopen( ArchivoDatos, "wb" ) )!=NULL ) { + + Poner_a_cero_estructura_actual_Eprom(); + Eprom1_inx.Fin = 0; + rewind(fa); + + fwrite(&cabecera, LSJ, 1, fa); fseek(fa, (long)LSJ, SEEK_SET); + fwrite(&Eprom1_inx, LSI, 1, fa); fseek(fa, (long)LSJ+LSI, SEEK_SET); + fwrite(&Eprom1, LSC, 1, fa); + + if (fclose(fa) == EOF ) exit(1); + } + + if ( (Eprom = fopen( ArchivoDatos, "r+b"))==NULL) { + restorecrtmode(); + printf("NO SE PUDO ABRIR EL FICHERO INDICE EN LA 2 PASADA"); + exit(1); + } + } + rewind(Eprom); + if ( fread(&cabecera, LSJ, 1, Eprom) != 1 ) { + restorecrtmode(); + printf("NO SE PUDO LEER EN EL FICHERO: INDICE"); + exit(1); + } + + if(cabecera.esc != 27 || cabecera.pt != 7 || cabecera.ef != 26 ) { + return -1; + // Cabecera no valida ((ERROR LEYENDO ESTRUCTURAS)) + } + + + fseek(Eprom, (long)LSJ, SEEK_SET); + if ( fread(&Eprom1_inx, LSI, 1, Eprom) != 1 ) { + restorecrtmode(); + printf("NO SE PUDO LEER EN EL FICHERO: INDICE"); + exit(1); + } + fseek(Eprom, (long)LSJ+LSI, SEEK_SET); + if ( fread(&Eprom1, LSC, 1, Eprom) != 1 ) { + restorecrtmode(); + printf("NO SE PUDO LEER EN EL FICHERO: DATOS"); + exit(1); + } + + return 1; +} + + +// DeleteRecordEprom +// +// Borra una linea de datos del fichero. +// + +void DeleteRecordEprom(void) { + +unsigned int CurrRecord; + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Eprom_inx); + int LSC = sizeof(struct Eprom_s); + +CurrRecord = CurrTopLineEprom + CurrRowEprom1 - 1; + + if ( (Eprom1_inx.Fin == 0) ) BEEP(); else { + + Eprom1_inx.Fin -= 1; + + unsigned int p = CurrRecord - 1; + + while( p <= Eprom1_inx.Fin ) { + + fseek(Eprom, (long)LSJ + LSI + ( LSC * ( p + 1 ) ), SEEK_SET); // Se coloca + fread(&Eprom1, LSC, 1, Eprom); // Y lee + + fseek(Eprom, (long)LSJ + LSI + ( LSC * p ), SEEK_SET); // Se coloca + fwrite(&Eprom1, LSC, 1, Eprom); // Y escribe + + p++; + }; + + fseek(Eprom, (long)LSJ, SEEK_SET); + fwrite(&Eprom1_inx, LSI, 1, Eprom); // Acualiza n de registros + +/* */ if ((CurrRecord - 1) == Eprom1_inx.Fin + 1) CurrRowEprom1--; +/* */ +/* */ PrintWholeScreenEprom(); +/* */ GetLineEprom(); + EditCursorEprom(0); + +// PrintLineEprom(); + } +} + + +// AddRecordEprom +// +// Aade una linea de datos del fichero. +// + +void AddRecordEprom(void){ + +unsigned int CurrRecord= CurrTopLineEprom + CurrRowEprom1 - 1; + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Eprom_inx); + int LSC = sizeof(struct Eprom_s); + double long ExP = 1; + + for(int i=1; i <= ((S_Eprom[CurrEprom].DM)/8); i++ ) ExP = ExP * 256; + +if(CurrRecord < ExP ) { + + long avance = Eprom1_inx.Fin /*+ 1*/; + + while( avance >= (CurrRecord-1) ) { + + fseek(Eprom, (long)LSJ + LSI + ( LSC * avance ), SEEK_SET); // Se coloca + fread(&Eprom1, LSC, 1, Eprom); // Y lee + + fseek(Eprom, (long)LSJ + LSI + ( LSC * (avance + 1) ), SEEK_SET); // Se coloca + fwrite(&Eprom1, LSC, 1, Eprom); // Y escribe + + avance--; + }; + + Eprom1_inx.Fin++; + + fseek(Eprom, (long)LSJ, SEEK_SET); + fwrite(&Eprom1_inx, LSI, 1, Eprom); // Acualiza n de registros + + Eprom1.Direccion ++; + Eprom1.Dato = 0; + + fseek(Eprom, (long)LSJ + LSI + ( LSC * ( CurrTopLineEprom + CurrRowEprom1 - 1) ), SEEK_SET); // Se coloca + fwrite(&Eprom1, LSC, 1, Eprom); // Y escribe + + CurrRowEprom1++; + + if (CurrRowEprom1>25) { + CurrTopLineEprom += /*28*/25; + if ( (CurrTopLineEprom+CurrRowEprom1) > Eprom1_inx.Fin) { CurrTopLineEprom = Eprom1_inx.Fin; CurrRowEprom1 = 2; } + if (CurrTopLineEprom==0) CurrTopLineEprom = 1; + PrintWholeScreenEprom(); + GetLineEprom(); + EditCursorEprom(0); + } else { + GetLineEprom(); + PrintLineEprom(); + } + + EditCursorEprom(0); + + + } + +} + +// PutLineEprom +// +// Guarda la actual linea de datos. +// + +void PutLineEprom(void){ + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Eprom_inx); + int LSC = sizeof(struct Eprom_s); + + int CurrRecord = CurrTopLineEprom + CurrRowEprom1 - 1; + +fseek(Eprom, (long)LSJ + LSI + ( LSC * CurrRecord ) - LSC, SEEK_SET); // Se coloca +fwrite(&Eprom1, LSC, 1, Eprom); // Y escribe + +} + +// GetLineEprom +// +// Obtiene la actual linea de datos. +// + +void GetLineEprom(void){ + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Eprom_inx); + int LSC = sizeof(struct Eprom_s); + + int CurrRecord = CurrTopLineEprom + CurrRowEprom1 - 1; + +fseek(Eprom, (long)LSJ + LSI + ( LSC * CurrRecord ) - LSC, SEEK_SET); // Se coloca +fread(&Eprom1, LSC, 1, Eprom); // Y lee + + +} + +// +// +// +// +// +// +// +// + +// +// Copia un archivo +// + + +int fcopy(char *origen, char *destino) { + + + FILE *in, *out; + char ch; + + if((in=fopen(origen, "rb"))==NULL){ + return (-1); + } + if((out=fopen(destino, "wb"))==NULL) { + return (-1); + } + + while(!feof(in)) putc(getc(in),out); + + fclose(in); + fclose(out); + + return 1; +} + +// Poner_a_cero_es... +// +// Inizializa las estructuras de datos de la cabecera y siguientes. +// + +void Poner_a_cero_estructura_actual_Eprom(void){ + + cabecera.esc = 27; strcpy(cabecera.color, "[31;40m"); + strcpy(cabecera.prog, "Jos David Guilln Dominguez"); + cabecera.nl = 13; cabecera.rt = 10; +// strcpy(cabecera.autor, " 6 / Mayo / 1995 "); + cabecera.pt = 7; cabecera.ef = 26; + + strcpy(cabecera.Comentario[0], "\0"); + strcpy(cabecera.Comentario[1], "\0"); + strcpy(cabecera.Comentario[2], "\0"); + strcpy(cabecera.Comentario[3], "\0"); + + Eprom1.Direccion = 0; + Eprom1.Dato = 0; + + +} + +// CompruebaLineasEprom +// +// Comprueba la pulsacin del raton sobre una linea y se posiciona. +// + +void CompruebaLineasEprom(void){ + // Check una pulsacion sobre un campo, y se situa, si es posible + int ok_p=0, inc=0, md=0; + int oldr, oldc; +// Anclar_Raton(); + + do{ + inc++; + if(x_raton >= (PC[(inc)-1].left+2) && x_raton <= (PC[inc-1].right-2) ) { ok_p=1; md = 1; + oldc=inc; } + if(inc==4) ok_p=1; + }while(!ok_p); + if(md==1){ + inc=0; ok_p=0; md = 0; + do{ + inc++; + if( (y_raton >= (PC[(oldc)-1].up+4+(inc-1)*15+2)) && (y_raton <= (PC[oldc-1].up+4+(inc-1)*15+16)) ) { ok_p=1; oldr=inc; md = 1;} + if(inc==25) ok_p=1; + }while(!ok_p); + } + int newc; + + if( (md==1) && ((CurrColEprom1!=newc) || (CurrRowEprom1!=oldr)) ) + { + + if( (CurrTopLineEprom + oldr - 2 )<= Eprom1_inx.Fin ){ + EditCursorEprom(1); + if(oldc!=CurrColEprom1 || oldr!=CurrRowEprom1){ + CurrColEprom1 = oldc; + CurrRowEprom1 = oldr; + GetLineEprom(); + } else EditCursorEprom(0); + } + } + + } diff --git a/EPROM-II.DSK b/EPROM-II.DSK new file mode 100644 index 0000000..9d3aa63 Binary files /dev/null and b/EPROM-II.DSK differ diff --git a/EPROM-II.EXE b/EPROM-II.EXE new file mode 100644 index 0000000..f804f31 Binary files /dev/null and b/EPROM-II.EXE differ diff --git a/EPROM-II.H b/EPROM-II.H new file mode 100644 index 0000000..776c272 --- /dev/null +++ b/EPROM-II.H @@ -0,0 +1,86 @@ +// MACROS +#define Texto_Normal setcolor(63); +#define Operacion_Fallida -1; + +// Estructuras +struct JD { + char esc; char color[8];char prog[50];char nl;char rt;char pt;char ef; + char Comentario[4][31]; // 30 * 4 --> Estandar <-- +}; + +struct Eprom_Structura { + + char TP; char FI; char NP; + char DM; char BD; long ID; + char ID_TEXT[15]; + +}; + +struct Eprom_inx { long Fin; }; + +struct Eprom_s { unsigned long Direccion; unsigned int Dato; }; + +struct JD cabecera; +struct JD cabecera2; +struct Eprom_s Eprom1; +struct Eprom_inx Eprom1_inx; +struct Eprom_Structura far *S_Eprom; +struct boton { int left; int up; int right; int down; } PC[4]; + + +// Prototipos + +void EditCursorEprom_CE(int SH, int CurrRowCE, int CurrTopLineCE); +void Carga_Cien_Elementos(struct Eprom_s *Datos); +void Poner_a_cero_estructura_actual_Eprom(void); +void Imprimir_Eprom(int desde, int hasta); +void Lee_Archivos_Presentes(int add_new); +void PrintEprom_CE_WholeScreen(int tmp); +void PrintWholeScreenCabecera(void); +void EditCursorEprom(int ShowHide); +void Fuente( int Font, int size); +void PrintWholeScreenEprom(void); +void PrintWholeScreenFile(void); +void CompruebaLineasEprom(void); +void Imprime_Eprom_Actual(void); +void Mueve_Arriba_Eprom(void); +void Mueve_Abajo_Eprom(void); +void DeleteRecordEprom(void); +void Salvar_Cargar(int S_C); +void EditCursorFile(int SH); +void Salvar_Cargar(int S_C); +void Edit_Item_Eprom(void); +void Menu_de_Edicion(void); +void PrintLineEprom(void); +void AddRecordEprom(void); +void Edit_Item_File(void); +void PutLineEprom(void); +void GetLineEprom(void); +void InicializaPc(void); +void Escoge_Eprom(void); +void BEEP(void); + +int Leer_en_Eprom(void); +int Abre_Ficha_Eprom(void); +int Comprueba_Impresora(void); +int Lee_Eproms(FILE *fichero); +int LeeCabecera(char *fichero); +int fcopy(char *origen, char *destino); +int InputCadenaG_l(char *s, int numalp, int lmax, int cc, int cf, struct boton Campo, int RoW); + + +// V. Globales + +int CurrRowFile, CurrColFile, CurrTopFile, + CurrRowCom, N_Files; +int N_Eprom = 0; int CurrEprom = 0; +int CurrRowEprom1 = 1, CurrColEprom1 = 1, CurrTopLineEprom = 1; +int key, Modifica_Direccion = 0; +long longitud = 0; + +char ArchivoDatos[]="Eprom_JD.TMP", Archivo[13];; +char *Archivo_list; + + +FILE *Eprom, *EpromC; + diff --git a/EPROM-II.PRJ b/EPROM-II.PRJ new file mode 100644 index 0000000..66a232d Binary files /dev/null and b/EPROM-II.PRJ differ diff --git a/EPROM.DAT b/EPROM.DAT new file mode 100644 index 0000000..7f61781 --- /dev/null +++ b/EPROM.DAT @@ -0,0 +1,73 @@ +* +* +* Este es el fichero de Datos, para las EPROM. +* +* +* Con una sencilla sintaxis, se pueden adir nuevos tipos de Eprom +* +* sin que ello afecte a la programacin global. +* +* Nuevas tecnicas de auto-reconfiguracin para el programa. +* Cdigo de reconfiguracin totalmente fiable +* Mejor sintaxis, para un uso mas sencillo +* +* +* +* +* Cada vez que se aada una nueva Eprom solo hay que incremetar en uno +* la variable N +* +* N --> N de Eprom's que se pueden programar +* +* + +* +* +* Sintaxis operativa: +* +* % [TP], [FI], [NP], [DM], [BD], [ID], [ID_TEXT]. +* +* TP -------> Tensin de programacin +* FI -------> Frecuencia de impulso (en micro-segundos). +* NP -------> N de patillas +* DM -------> Direccin mas alta ( en Bit's ) +* BD -------> N de Bit's del dato +* ID -------> Cdigo nmerico identificativo de la Eprom +* ID_TEXT --> Texto indicativo del tipo de Eprom (12 dig + '.') +* +* + +N24 + +% 50, 50, 72, 8, 8, 50312345, Jos David . + +% 50, 50, 72, 16, 16, 23425000, 123PC18 DX/2. + +% 50, 50, 72, 11, 8, 50312340, JD FUTURE 01. + +% 50, 50, 72, 16, 8, 50312345, MICRO CHIPPP. + +% 50, 50, 72, 16, 16, 50312345, Eprom 'HOLA'. + +% 50, 50, 72, 16, 16, 50312345, JD F.V . + +% 50, 50, 72, 16, 16, 50312345, Sol Negro . + +% 50, 50, 72, 16, 8, 50312345, CAPTAIN ZAP . + +% 50, 50, 72, 16, 8, 50312345, Eprom 8 . +% 50, 50, 72, 16, 8, 50312345, Eprom 9 . +% 50, 50, 72, 16, 8, 50312345, Eprom 10 . +% 50, 50, 72, 16, 8, 50312345, Eprom 11 . +% 50, 50, 72, 16, 8, 50312345, Eprom 12 . +% 50, 50, 72, 16, 8, 50312345, Eprom 13 . +% 50, 50, 72, 16, 8, 50312345, Eprom 14 . +% 50, 50, 72, 16, 8, 50312345, Eprom 15 . +% 50, 50, 72, 16, 8, 50312345, Eprom 16 . +% 50, 50, 72, 16, 8, 50312345, Eprom 17 . +% 50, 50, 72, 16, 8, 50312345, Eprom 18 . +% 50, 50, 72, 16, 8, 50312345, Eprom 19 . +% 50, 50, 72, 16, 8, 50312345, Eprom 20 . +% 50, 50, 72, 16, 8, 50312345, Eprom 21 . +% 50, 50, 72, 16, 8, 50312345, Eprom 22 . +% 50, 50, 72, 16, 8, 50312345, Eprom 23 . diff --git a/EPROM.JDF b/EPROM.JDF new file mode 100644 index 0000000..f14df38 --- /dev/null +++ b/EPROM.JDF @@ -0,0 +1,183 @@ +* +* +* Este es el interfaz de rutinas Grficas del programador de Eprom's +* +* lenguaje de interfaz grficos ( JDf ) creado por JD FuTuRe ViSiOn +* +* Por Favor, no modifique el cdigo original. +* +* + +* +* +* Rutinas creadas y totalmente escritas en C estandar. +* +* Libreria BETA ya disponible, Grandes rendimientos GRAFICOS a muy bajo +* +* coste de produccion. ( Precio de la libreria: 1_FUENTE EN C, CPP, ASM ) +* +* + + +1 +************ Toda la Pantalla ********** +& 0, 0, 640, 480, 57, 56, 63, 2, 2 +************ Barra de Ayuda ********** +& 450, 5, 635, 475, 7, 63, 56, 2, 2 + + + + +2 +************ Azul Tapa ********** +& 10, 301, 309, 445, 57, 57, 57, 2, 2 + +************ Direccion ********** +& 10, 5, 300, 445, 7, 63, 56, 1, 2 + +& 15, 10, 122, 40, 0, 56, 63, 1, 2 +& 15, 132, 295, 40, 0, 56, 63, 2, 2 + +& 50, 10, 122, 440, 0, 56, 63, 2, 2 +& 50, 132, 295, 440, 0, 56, 63, 2, 2 + +************ Dato ********** +& 10, 310, 540, 445, 7, 63, 56, 1, 2 + +& 15, 315, 398, 40, 0, 56, 63, 2, 2 +& 15, 408, 535, 40, 0, 56, 63, 2, 2 + +& 50, 315, 398, 440, 0, 56, 63, 2, 2 +& 50, 408, 535, 440, 0, 56, 63, 2, 2 + +************ Letras ********** +| 10, 17, 2, 6, 0, 63, Hex., +| 132, 17, 2, 6, 0, 63, Dec., + +| 315, 17, 2, 6, 0, 63, Hex., +| 440, 17, 2, 6, 0, 63, Dec., + +| 545, 15, 2, 6, 0, 63, Eprom, +| 545, 22, 2, 6, 0, 1, , + | 546, 16, 2, 6, 0, 0, Eprom, + | 546, 23, 2, 6, 0, 63, , + +& 40, 550, 630, 55, 0, 63, 56, 1, 1 + +| 549, 75, 2, 5, 0, 63, Direccin, +| 549, 82, 2, 5, 0, 1, , + | 550, 76, 2, 5, 0, 0, Direccin, + | 550, 83, 2, 5, 0, 63, , + +& 100, 615, 630, 115, 0, 63, 56, 1, 1 +| 545, 195, 2, 6, 0, 63, Cargar, +| 545, 202, 2, 6, 0, 1, , + | 546, 196, 2, 6, 0, 0, Cargar, + | 546, 203, 2, 6, 0, 63, , + +| 545, 237, 2, 6, 0, 63, Grabar, +| 545, 244, 2, 6, 0, 1, , + | 546, 238, 2, 6, 0, 0, Grabar, + | 546, 245, 2, 6, 0, 63, , + +| 545, 286, 2, 5, 0, 63, Leer Eprom, +| 545, 293, 2, 5, 0, 1, , + | 546, 287, 2, 5, 0, 0, Leer Eprom, + | 546, 294, 2, 5, 0, 63, , + + +| 545, 335, 2, 5, 0, 63, Enviar, +| 545, 350, 2, 5, 0, 63, Datos a, +| 544, 356, 2, 5, 0, 1, , +| 545, 365, 2, 5, 0, 63, Eprom, + | 546, 336, 2, 5, 0, 0, Enviar, + | 546, 351, 2, 5, 0, 0, Datos a, + | 545, 357, 2, 5, 0, 63, , + | 546, 366, 2, 5, 0, 0, Eprom, + +| 545, 400, 2, 6, 0, 63, Salir, +| 545, 407, 2, 6, 0, 1, , + | 546, 401, 2, 6, 0, 0, Salir, + | 546, 408, 2, 6, 0, 63, , + +| 545, 140, 2, 6, 0, 63, Imprimir, +| 545, 147, 2, 6, 0, 1, , + | 546, 141, 2, 6, 0, 0, Imprimir, + | 546, 148, 2, 6, 0, 63, , + +3 +& 150, 170, 470, 330, 7, 63, 56, 2, 2 + & 155, 245, 290, 170, 0, 56, 63, 1, 2 + + +& 175, 175, 465, 190, 0, 56, 63, 2, 2 + +& 195, 175, 465, 325, 0, 56, 63, 2, 2 + +| 175, 152, 2, 6, 0, 63, Eprom de [ ], +| 176, 153, 2, 6, 0, 0, Eprom de [ ], + +| 175, 176, 2, 4, 0, 63, TP FI NP DM BD Numero ID Tipo de Eprom, + + +4 + +& 150, 170, 470, 330, 7, 63, 56, 2, 2 + +& 155, 270, 465, 170, 0, 56, 63, 1, 2 + +& 175, 175, 265, 325, 0, 56, 63, 2, 2 + +****** Comentario 4 * 30digitos +& 200, 270, 465, 250, 0, 56, 63, 2, 2 + +& 295, 270, 365, 325, 7, 63, 56, 2, 2 +& 295, 370, 465, 325, 7, 63, 56, 2, 2 + + + +**** Versin ShareWare +| 260, 250, 2, 6, 0, 1, Versin ShareWare, +| 260, 265, 2, 4, 0, 2, V. Completa: Software 5.000 ptas. +| 260, 275, 2, 4, 0, 2, Placa 15.000 ptas. + +| 175, 152, 2, 6, 0, 63, Archivo: , +| 176, 153, 2, 6, 0, 0, Archivo: , + +| 275, 300, 2, 6, 0, 63, Aceptar , +| 276, 301, 2, 6, 0, 0, Aceptar , + | 275, 302, 2, 6, 0, 63, _, + | 276, 303, 2, 6, 0, 0, _, + +| 370, 300, 2, 6, 0, 63, Cancelar , +| 371, 301, 2, 6, 0, 0, Cancelar , + | 370, 302, 2, 6, 0, 63, _, + | 371, 303, 2, 6, 0, 0, _, + +| 270, 180, 2, 6, 0, 63, Comentario: , +| 271, 181, 2, 6, 0, 0, Comentario: , + +*| 175, 176, 2, 4, 0, 63, TP FI NP DM BD Numero ID Tipo de Eprom, + +#2 +!1,8 +$ 10, 545, 635, 60, 7, 56, 63, 2, 1, 00, 18 +$ 70, 545, 635, 120, 7, 56, 63, 2, 1, 00, 32 + +******** Modificar cdigo de chequeo ****************** +$ 130, 545, 635, 180, 7, 56, 63, 2, 1, 00, 23 + +$ 190, 545, 635, 222, 7, 56, 63, 2, 1, 00, 46 +$ 232, 545, 635, 265, 7, 56, 63, 2, 1, 00, 34 + +$ 275, 545, 635, 325, 7, 56, 63, 2, 1, 00, 38 +$ 335, 545, 635, 385, 7, 56, 63, 2, 1, 00, 30 +$ 395, 545, 635, 445, 7, 56, 63, 2, 1, 00, 31 + +!2,2 + +$ 295, 270, 365, 325, 7, 63, 56, 2, 2, 00, 30 +$ 295, 370, 465, 325, 7, 63, 56, 2, 2, 00, 46 + + + diff --git a/EPROM_JD b/EPROM_JD new file mode 100644 index 0000000..af3d5c1 Binary files /dev/null and b/EPROM_JD differ diff --git a/EPROM_JD.TMP b/EPROM_JD.TMP new file mode 100644 index 0000000..d62027a Binary files /dev/null and b/EPROM_JD.TMP differ diff --git a/EP_2.CPP b/EP_2.CPP new file mode 100644 index 0000000..c9d52c2 --- /dev/null +++ b/EP_2.CPP @@ -0,0 +1,447 @@ +#include +#include +#include +#include +#include +#include + +#define DIBUJA 1 +#define DEPRIME 2 +#define Dibuja_Todos 3 +#define COMPRUEBA 4 +#define STD_BY 5 + +void Edit_Item(void); +void espera_soltar(void); +void espera_pulsar(void); +void activa_raton(void); +void desactiva_raton(void); +void inicializa_raton_texto(void); +void Pantalla_Leer(void); +void Pantalla_Escribir(void); +void dibuja_pantalla(void); +struct Boton_Texto{ + char x; char y; + char Texto[80]; + + int ID_T1; + int ID_T2; +}; + +int Funcion_Botones(int Funcion, int nBotones, struct Boton_Texto *Boton_Texto); + + struct byte_de_long { unsigned char P3; unsigned char P2; + unsigned char P1; unsigned char P0; + }; + union lngchr{ long Numero; struct byte_de_long Byte; } Division; + ////////////////////////////// + // long --> FF FF FF FF --> 3 34 65 59 + // P0 P1 P2 P3 Dec.89 101 52 3 + ////////////////////////////// Hex.59 65 34 3 +int boton_izq; int boton_der; +int x_raton, y_raton, RATON = 1; +int SWAP = 0; +int Dir, Dato; + +void main(void){ + +struct Boton_Texto BT[6]; +int devolver = 0, i; + +BT[0].x = 58; BT[0].y = 3; strcpy( BT[0].Texto, " P. &Leer "); BT[0].ID_T1 = 76; BT[0].ID_T2 = 0; +BT[1].x = 58; BT[1].y = 6; strcpy( BT[1].Texto, " Iniciar Lec&tura "); BT[1].ID_T1 = 84; BT[1].ID_T2 = 0; + +BT[2].x = 58; BT[2].y = 9; strcpy( BT[2].Texto, " P. &Escribir "); BT[2].ID_T1 = 69; BT[2].ID_T2 = 0; +BT[3].x = 58; BT[3].y =12; strcpy( BT[3].Texto, " Iniciar E&scritura "); BT[3].ID_T1 = 83; BT[3].ID_T2 = 0; + +BT[4].x = 58; BT[4].y =15; strcpy( BT[4].Texto, " &C R E D I T O S "); BT[4].ID_T1 = 67; BT[4].ID_T2 = 0; +BT[5].x = 58; BT[5].y =18; strcpy( BT[5].Texto, " S&ALIR de PDE ... "); BT[5].ID_T1 = 65; BT[5].ID_T2 = 0; + + inicializa_raton_texto(); + if( RATON ) desactiva_raton(); + dibuja_pantalla(); + _setcursortype(_NOCURSOR); + Pantalla_Leer(); +// while( !kbhit() ); +// Pantalla_Escribir(); + +while(devolver != 6) { + devolver = Funcion_Botones(STD_BY, 6, BT); + switch(devolver){ + case 1: Pantalla_Leer(); SWAP = 0; break; + case 2: + Pantalla_Leer(); SWAP = 0; + _setcursortype(_NORMALCURSOR); + Edit_Item(); + _setcursortype(_NOCURSOR); + + break; + case 3: Pantalla_Escribir(); SWAP = 1; break; + case 4: + Pantalla_Escribir(); SWAP = 1; + _setcursortype(_NORMALCURSOR); + Edit_Item(); + _setcursortype(_NOCURSOR); + + break; + case 6: break; + default: + while( kbhit() ) getch(); + break; + } + +} + + textbackground(BLACK); + _setcursortype(_NORMALCURSOR); +clrscr(); + +} + + +void dibuja_pantalla(void){ + + int i; + clrscr(); + highvideo(); + + window(1, 1, 80, 25); + textcolor(9); + textbackground(7); + for(i=0; i<27; i++) // "-.-.-.-.-.-.-.-.-.-.-.-." + cprintf(" "); + + textcolor(BLACK); + gotoxy(1,25); + cprintf("Utilidad para "); textcolor(RED); + cprintf("PDE _ EPROM2.EXE"); textcolor(BLACK); + gotoxy( (80-22), 25); cprintf("Jos David & Francisco"); + +} + +void Pantalla_Leer(void){ + highvideo(); + textcolor(BLACK); + textbackground(7); + gotoxy(3,3); cprintf(""); + gotoxy(17,3); cprintf(""); + gotoxy(3,4); cprintf(" Leer "); + textcolor(WHITE); cprintf(""); textcolor(BLACK); + gotoxy(17,4); cprintf(" Escribir "); + textcolor(WHITE); cprintf(""); textcolor(BLACK); + gotoxy(3,5); cprintf(" Ŀ"); + gotoxy(3,6); cprintf(" "); + gotoxy(3,7); cprintf(" Direccin: "); + gotoxy(3,8); cprintf(" "); + gotoxy(3,9); cprintf(" "); + gotoxy(3,10); cprintf(" "); + gotoxy(3,11); cprintf(" "); + textcolor(RED); + gotoxy(5,11); cprintf("Dato Leido:"); + textcolor(BLACK); + gotoxy(3,12); cprintf(" "); + gotoxy(3,13); cprintf(""); + + textcolor(WHITE); + gotoxy(4,3); cprintf(""); + gotoxy(18,3); cprintf(""); + + gotoxy(14,5); cprintf(""); + gotoxy(46,6); cprintf(""); + gotoxy(46,7); cprintf(""); + gotoxy(46,8); cprintf(""); + gotoxy(46,9); cprintf(""); + gotoxy(46,10); cprintf(""); + gotoxy(46,11); cprintf(""); + gotoxy(46,12); cprintf(""); + gotoxy(46,13); cprintf(""); + +} + + +void Pantalla_Escribir(void){ + highvideo(); + textcolor(BLACK); + textbackground(7); + gotoxy(3,3); cprintf(""); + gotoxy(17,3); cprintf(""); + gotoxy(3,4); cprintf(" Leer "); + textcolor(WHITE); cprintf(""); textcolor(BLACK); + gotoxy(17,4); cprintf(" Escribir "); + textcolor(WHITE); cprintf(""); textcolor(BLACK); + gotoxy(3,5); cprintf(" Ŀ"); + gotoxy(3,6); cprintf(" "); + gotoxy(3,7); cprintf(" Direccin: "); + gotoxy(3,8); cprintf(" "); + gotoxy(3,9); cprintf(" Dato: "); + gotoxy(3,10); cprintf(" "); + gotoxy(3,11); cprintf(" "); + textcolor(RED); + gotoxy(5,11); cprintf("Dato escrito:"); + textcolor(BLACK); + gotoxy(3,12); cprintf(" "); + gotoxy(3,13); cprintf(""); + + textcolor(WHITE); + gotoxy(4,3); cprintf(""); + gotoxy(18,3); cprintf(""); + + gotoxy(4,5); cprintf(" "); + gotoxy(46,6); cprintf(""); + gotoxy(46,7); cprintf(""); + gotoxy(46,8); cprintf(""); + gotoxy(46,9); cprintf(""); + gotoxy(46,10); cprintf(""); + gotoxy(46,11); cprintf(""); + gotoxy(46,12); cprintf(""); + gotoxy(46,13); cprintf(""); + +} + + +int Funcion_Botones(int Funcion, int nBotones, struct Boton_Texto *Boton_Texto){ + + char i, DEVOLVER = -1; + int longitud, key; + + switch( Funcion ) { + case DIBUJA: + highvideo(); + textcolor(BLACK); + textbackground(11); + gotoxy(Boton_Texto[nBotones].x, Boton_Texto[nBotones].y); + DEVOLVER = 0; + longitud = strlen( Boton_Texto[nBotones].Texto ); + while( DEVOLVER <= longitud ) { + if( Boton_Texto[nBotones].Texto[DEVOLVER] == '&' ) { + DEVOLVER ++; + textcolor(RED); + cprintf("%c", Boton_Texto[nBotones].Texto[DEVOLVER]); + textcolor(BLACK); + } else cprintf("%c", Boton_Texto[nBotones].Texto[DEVOLVER]); + DEVOLVER ++; + } + + // cprintf("%s", Texto); + + textbackground(7); // SALIR + cprintf(""); // + gotoxy(Boton_Texto[nBotones].x+1, Boton_Texto[nBotones].y+1); + for(i = 0; i < longitud; i ++ ) // + cprintf(""); // + break; + case DEPRIME: + highvideo(); + textcolor(BLACK); + textbackground(11); + gotoxy(Boton_Texto[nBotones].x, Boton_Texto[nBotones].y); + DEVOLVER = 0; + longitud = strlen( Boton_Texto[nBotones].Texto ); + textbackground(7); + while( DEVOLVER <= (longitud+1) ) { + if( Boton_Texto[nBotones].Texto[DEVOLVER] == '&' ) { + DEVOLVER ++; + } + cprintf(" "); + DEVOLVER ++; + } + textbackground(11); + gotoxy(Boton_Texto[nBotones].x+1, Boton_Texto[nBotones].y+1); + DEVOLVER = 0; + while( DEVOLVER <= longitud ) { + + if( Boton_Texto[nBotones].Texto[DEVOLVER] == '&' ) { + DEVOLVER ++; + textcolor(RED); + cprintf("%c", Boton_Texto[nBotones].Texto[DEVOLVER]); + textcolor(BLACK); + } else cprintf("%c", Boton_Texto[nBotones].Texto[DEVOLVER]); + DEVOLVER ++; + } +// cprintf("%s", Texto); // + // + break; + case Dibuja_Todos: + for( i=0; i < nBotones; i++) + Funcion_Botones( DIBUJA, i, Boton_Texto); + break; + case COMPRUEBA: + if( bioskey(1)!=0 ) { + key = toupper( getch() ); + for( i=0; i < nBotones && DEVOLVER <= -1; i++){ + if( key == Boton_Texto[i].ID_T1 ) { + if( key == 0 ) { + key = toupper( getch() ); + if( key == Boton_Texto[i].ID_T2 ){ + DEVOLVER = (i + 1); + Funcion_Botones( DEPRIME, (DEVOLVER-1), Boton_Texto); + delay(150); + //sleep(1); + Funcion_Botones( DIBUJA, (DEVOLVER-1), Boton_Texto); + } else DEVOLVER = -2; + } else + { DEVOLVER = (i + 1); + Funcion_Botones( DEPRIME, (DEVOLVER-1), Boton_Texto); + delay(150); + //sleep(1); + Funcion_Botones( DIBUJA, (DEVOLVER-1), Boton_Texto); + } + } + } + if( DEVOLVER == -1 ) + { ungetch(key); } + + if( DEVOLVER == -2 ) + { ungetch(0); ungetch(key); DEVOLVER = -1; } + + } else if( RATON ) { + for( i=0; i < nBotones && DEVOLVER == -1; i++) { + longitud = strlen( Boton_Texto[i].Texto ); + if ( (x_raton+1) >= Boton_Texto[i].x && (x_raton+1) <= ( Boton_Texto[i].x + longitud -1) && + y_raton == (Boton_Texto[i].y-1) ) { DEVOLVER = (i + 1); + Funcion_Botones( DEPRIME, (DEVOLVER-1), Boton_Texto); + if( RATON ) activa_raton(); + espera_soltar(); + if( RATON ) desactiva_raton(); +// delay(150); + Funcion_Botones( DIBUJA, (DEVOLVER-1), Boton_Texto); + } + } + } + break; + case STD_BY: + Funcion_Botones(Dibuja_Todos, 6, Boton_Texto); + do{ + if( RATON ) activa_raton(); + if( RATON ) espera_pulsar(); else while( bioskey(1)==0 ); + if( RATON ) desactiva_raton(); + DEVOLVER = Funcion_Botones(COMPRUEBA, 6, Boton_Texto); + }while(DEVOLVER==-1 && bioskey(1)==0 ); + + } + return DEVOLVER; +} + +void inicializa_raton_texto(void) +{ + union REGS ent, sal; + + ent.x.ax = 0; + int86(0x33, &ent, &sal); /* averigua si hay ratn conectado */ + + if(sal.x.ax==0) { RATON = 0; return; } + + ent.x.ax = 15; + ent.x.cx = 8; + ent.x.dx = 16; + int86(0x33, &ent, &sal); /* fija la razn mickey/pixel */ + + ent.x.ax = 7; + ent.x.cx = 0; + ent.x.dx = 639; + int86(0x33, &ent, &sal); /* fija la posicin mx. y mn. horizontal */ + + ent.x.ax = 8; + ent.x.cx = 0; + ent.x.dx = 199; + int86(0x33, &ent, &sal); /* fija la posicin mx. y mn. vertical */ + + ent.x.ax = 4; + ent.x.cx = 320; + ent.x.dx = 100; + int86(0x33, &ent, &sal); /* fija la posicin del ratn */ + + ent.x.ax = 1; + int86(0x33, &ent, &sal); /* muestra el puntero del ratn */ +} +void activa_raton(void) +{ + union REGS ent, sal; + + ent.x.ax = 1; + int86(0x33, &ent, &sal); +} + +void desactiva_raton(void) +{ + union REGS ent, sal; + + ent.x.ax = 2; + int86(0x33, &ent, &sal); +} + +void espera_pulsar(void) +{ + union REGS ent, sal; + + do{ + if(bioskey(1)!=0) break; + ent.x.ax = 3; + int86(0x33, &ent, &sal); /* lee posicin y estados del botn */ + }while((sal.x.bx & 3)==0); + boton_izq=sal.x.bx & 1; + boton_der=(sal.x.bx >> 1) & 1; + x_raton= (sal.x.cx >> 1) / 4; // / 8 + y_raton= (sal.x.dx)/8; // /8 +} + +void espera_soltar(void) +{ + union REGS ent, sal; + + do{ + ent.x.ax = 3; + int86(0x33, &ent, &sal); /* lee posicin y estados del botn */ + }while((sal.x.bx & 3)!=0); + boton_izq=sal.x.bx & 1; + boton_der=(sal.x.bx >> 1) & 1; + x_raton=sal.x.cx >> 1; + y_raton=sal.x.dx; +} + + +void Edit_Item(void){ + +char buffer[80]; +char *endptr; + + if( !SWAP ) { + + do{ + strcpy( buffer, "\0"); + gotoxy(16,7); textcolor(RED); + cprintf(" "); + gotoxy(16,7); + cscanf("%10s", buffer ); + + Dir = strtol(buffer, &endptr, 16); + }while(*endptr!=NULL); + + // LEER + } else { + // ESCRIBIR + + textcolor(RED); + gotoxy(16,7); + do{ + strcpy( buffer, "\0"); + gotoxy(16,7); textcolor(RED); + cprintf(" "); + gotoxy(16,7); + cscanf("%10s", buffer ); + Dir = strtol(buffer, &endptr, 16); + }while(*endptr!=NULL); + + do{ + strcpy( buffer, "\0"); + gotoxy(16,9); textcolor(RED); + cprintf(" "); + gotoxy(16,9); + cscanf("%10s", buffer ); + Dato = strtol(buffer, &endptr, 16); + }while(*endptr!=NULL); + + + } + +} diff --git a/EP_2.EXE b/EP_2.EXE new file mode 100644 index 0000000..93e4324 Binary files /dev/null and b/EP_2.EXE differ diff --git a/LITT.CHR b/LITT.CHR new file mode 100644 index 0000000..08c3067 Binary files /dev/null and b/LITT.CHR differ diff --git a/NONAME00.CPP b/NONAME00.CPP new file mode 100644 index 0000000..e1b1ff6 --- /dev/null +++ b/NONAME00.CPP @@ -0,0 +1,33 @@ +#include + + + + + struct byte_de_long { unsigned char P3; unsigned char P2; + unsigned char P1; unsigned char P0; + }; + union lngchr{ long Numero; struct byte_de_long Byte; } Division; + ////////////////////////////// + // long --> FF FF FF FF --> 3 34 65 59 + // P0 P1 P2 P3 Dec.89 101 52 3 + ////////////////////////////// Hex.59 65 34 3 + +void main(void){ + int iP0, iP1, iP2, iP3; + clrscr(); + cscanf("%ld", &Division.Numero ); + cprintf("\r\n"); + cprintf("LONG --> %ld", Division.Numero); + cprintf("\r\n"); + cprintf("Bytes de un long:\r\n"); + iP0 = Division.Byte.P0; + iP1 = Division.Byte.P1; + iP2 = Division.Byte.P2; + iP3 = Division.Byte.P3; + cprintf("P3 --> %d P2 --> %d P1 --> %d P0 --> %d\r\n", iP3, iP2, iP1, iP0); + cprintf("\r\n"); + + + + +} \ No newline at end of file diff --git a/R.BAT b/R.BAT new file mode 100644 index 0000000..83d3219 --- /dev/null +++ b/R.BAT @@ -0,0 +1 @@ +edit eprom.jdf diff --git a/RATON.C b/RATON.C new file mode 100644 index 0000000..7060e44 --- /dev/null +++ b/RATON.C @@ -0,0 +1,574 @@ + +#include +#include +#include +#include +#include + +#define ALFANUMERICO 0x03 +#define GRAFICO 0x13 + +void DIBUJA_BLOQUE_SIN_MASK_CUT(int *, char *, char *); +void DIBUJA_BLOQUE_CON_MASK_CUT(int *, char *, char *); +void VUELCA_PANTALLA(int,int, int,int, int,int, char *); +void pantalla_cine(void); +void cinta_cine(void); +void premios(void); +void premiados(void); +void espera_pulsar(void); +void espera_soltar(void); +void no_hay_raton(void); +void desactiva_raton(void); +void activa_raton(void); +void dibuja_graficos(void); +void inicializa_raton_texto(void); +void inicializa_raton_grafico(void); +void salir_al_dos(void); +void asigna_modo_video(char); +void lee_dibujos(char *); +void descomprime_dibujo(char *); +void asigna_rgb(char *); +void asigna_memoria(void); +void libera_memoria(void); + +int x_raton; +int y_raton; +int y_raton_ant; +int boton_izq; +int boton_der; +int pos_playa [6] = { 0, 0, 0, 0, 320,200 }; +int pos_toalla [8] = { 188, 0, 188,47, 130,152, 87, 47 }; +int pos_sombrilla [8] = { 0, 0, 94, 0, 175,110, 94, 70 }; +int pos_pelota [8] = { 275, 0, 275,23, 185,170, 25, 23 }; +char fichero1 [] = { "raton1.pcx" }; +char fichero2 [] = { "raton2.pcx" }; +int dir_raton [32+32] = { 0x3FFF, /* mscara del cursor */ + 0x1FFF, + 0x0FFF, + 0x07FF, + 0x03FF, + 0x01FF, + 0x00FF, + 0x007F, + 0x003F, + 0x001F, + 0x000F, + 0x0007, + 0x0007, + 0xF81F, + 0xFC0F, + 0xFE0F, + + 0x0000, /* dibujo del cursor */ + 0x4000, + 0x6000, + 0x7000, + 0x7800, + 0x7C00, + 0x7E00, + 0x7F00, + 0x7F80, + 0x7FC0, + 0x7FE0, + 0x7FF0, + 0x0780, + 0x03C0, + 0x01E0, + 0x0000 }; +char color_izq=DARKGRAY; +char color_der=BROWN; +char *dir_carga_dibujos; +char *dir_dibujo1; +char *dir_dibujo2; +char *dir_zona_pantalla; +FILE *handle_dibujos; + +/*//////////////////////////////// PROGRAMA ////////////////////////////////*/ + +void main(void) +{ + union REGS ent, sal; + + asigna_memoria(); + + asigna_modo_video(ALFANUMERICO); + inicializa_raton_texto(); + desactiva_raton(); + pantalla_cine(); + cinta_cine(); + premios(); + activa_raton(); + while(bioskey(1)!=0) bioskey(0); + + do{ + espera_pulsar(); + desactiva_raton(); + if(boton_izq==1) color_izq=LIGHTGRAY; + if(boton_der==1) color_der=YELLOW; + cinta_cine(); + premiados(); + activa_raton(); + espera_soltar(); + desactiva_raton(); + if(boton_izq==0) color_izq=DARKGRAY; + if(boton_der==0) color_der=BROWN; + cinta_cine(); + premios(); + activa_raton(); + }while(bioskey(1)==0); + + asigna_modo_video(GRAFICO); + lee_dibujos(fichero1); + descomprime_dibujo(dir_dibujo1); + lee_dibujos(fichero2); + descomprime_dibujo(dir_dibujo2); + + inicializa_raton_grafico(); + DIBUJA_BLOQUE_SIN_MASK_CUT(pos_playa, dir_dibujo1, dir_zona_pantalla); + DIBUJA_BLOQUE_CON_MASK_CUT(pos_toalla, dir_dibujo2, dir_zona_pantalla); + DIBUJA_BLOQUE_CON_MASK_CUT(pos_pelota, dir_dibujo2, dir_zona_pantalla); + DIBUJA_BLOQUE_CON_MASK_CUT(pos_sombrilla, dir_dibujo2, dir_zona_pantalla); + desactiva_raton(); + VUELCA_PANTALLA(0,0, 0,0, 320,200, dir_zona_pantalla); + activa_raton(); + while(bioskey(1)!=0) bioskey(0); + + do{ + ent.x.ax = 3; + int86(0x33, &ent, &sal); /* lee posicin y estados del botn */ + boton_izq=sal.x.bx & 1; + boton_der=(sal.x.bx >> 1) & 1; + + if((boton_izq==1 || boton_der==1) && + x_raton>=pos_toalla[4]+(pos_toalla[6]/2)-4 && + x_raton<=pos_toalla[4]+(pos_toalla[6]/2)+4 && + y_raton>=pos_toalla[5]+(pos_toalla[7]/2)-4 && + y_raton<=pos_toalla[5]+(pos_toalla[7]/2)+4) { + pos_toalla[4]=(sal.x.cx >> 1)-(pos_toalla[6]/2); + pos_toalla[5]=(sal.x.dx )-(pos_toalla[7]/2); + dibuja_graficos(); + desactiva_raton(); + VUELCA_PANTALLA(0,0, 0,0, 320,200, dir_zona_pantalla); + activa_raton(); + } + else if((boton_izq==1 || boton_der==1) && + x_raton>=pos_pelota[4]+(pos_pelota[6]/2)-4 && + x_raton<=pos_pelota[4]+(pos_pelota[6]/2)+4 && + y_raton>=pos_pelota[5]+(pos_pelota[7]/2)-4 && + y_raton<=pos_pelota[5]+(pos_pelota[7]/2)+4) { + pos_pelota[4]=(sal.x.cx >> 1)-(pos_pelota[6]/2); + pos_pelota[5]=(sal.x.dx )-(pos_pelota[7]/2); + dibuja_graficos(); + desactiva_raton(); + VUELCA_PANTALLA(0,0, 0,0, 320,200, dir_zona_pantalla); + activa_raton(); + } + else if((boton_izq==1 || boton_der==1) && + x_raton>=pos_sombrilla[4]+(pos_sombrilla[6]/2)-4 && + x_raton<=pos_sombrilla[4]+(pos_sombrilla[6]/2)+4 && + y_raton>=pos_sombrilla[5]+(pos_sombrilla[7]/2)-4 && + y_raton<=pos_sombrilla[5]+(pos_sombrilla[7]/2)+4) { + pos_sombrilla[4]=(sal.x.cx >> 1)-(pos_sombrilla[6]/2); + pos_sombrilla[5]=(sal.x.dx )-(pos_sombrilla[7]/2); + dibuja_graficos(); + desactiva_raton(); + VUELCA_PANTALLA(0,0, 0,0, 320,200, dir_zona_pantalla); + activa_raton(); + } + x_raton=sal.x.cx >> 1; + y_raton=sal.x.dx; + }while(bioskey(1)==0); + while(bioskey(1)!=0) bioskey(0); + + salir_al_dos(); +} + +void dibuja_graficos(void) +{ + DIBUJA_BLOQUE_SIN_MASK_CUT(pos_playa, dir_dibujo1, dir_zona_pantalla); + DIBUJA_BLOQUE_CON_MASK_CUT(pos_toalla, dir_dibujo2, dir_zona_pantalla); + DIBUJA_BLOQUE_CON_MASK_CUT(pos_pelota, dir_dibujo2, dir_zona_pantalla); + DIBUJA_BLOQUE_CON_MASK_CUT(pos_sombrilla, dir_dibujo2, dir_zona_pantalla); +} + +void inicializa_raton_texto(void) +{ + union REGS ent, sal; + + ent.x.ax = 0; + int86(0x33, &ent, &sal); /* averigua si hay ratn conectado */ + + if(sal.x.ax==0) no_hay_raton(); + + ent.x.ax = 15; + ent.x.cx = 8; + ent.x.dx = 16; + int86(0x33, &ent, &sal); /* fija la razn mickey/pixel */ + + ent.x.ax = 7; + ent.x.cx = 0; + ent.x.dx = 639; + int86(0x33, &ent, &sal); /* fija la posicin mx. y mn. horizontal */ + + ent.x.ax = 8; + ent.x.cx = 0; + ent.x.dx = 199; + int86(0x33, &ent, &sal); /* fija la posicin mx. y mn. vertical */ + + ent.x.ax = 4; + ent.x.cx = 320; + ent.x.dx = 100; + int86(0x33, &ent, &sal); /* fija la posicin del ratn */ + + ent.x.ax = 1; + int86(0x33, &ent, &sal); /* muestra el puntero del ratn */ +} + +void inicializa_raton_grafico(void) +{ + struct SREGS seg; + union REGS ent, sal; + long dir; + + ent.x.ax = 0; + int86(0x33, &ent, &sal); /* averigua si hay ratn conectado */ + + if(sal.x.ax==0) no_hay_raton(); + + ent.x.ax = 15; + ent.x.cx = 5; + ent.x.dx = 12; + int86(0x33, &ent, &sal); /* fija la razn mickey/pixel */ + + ent.x.ax = 7; + ent.x.cx = 0; + ent.x.dx = 639; + int86(0x33, &ent, &sal); /* fija la posicin mx. y mn. horizontal */ + + ent.x.ax = 8; + ent.x.cx = 0; + ent.x.dx = 199; + int86(0x33, &ent, &sal); /* fija la posicin mx. y mn. vertical */ + + dir = (long)dir_raton; + ent.x.ax = 9; + ent.x.bx = 0; + ent.x.cx = 0; + ent.x.dx = (int) dir; + seg.es = (int)(dir >> 16); + int86x(0x33, &ent, &sal, &seg); /* asigna un cursor diferente */ + + ent.x.ax = 4; + ent.x.cx = 320; + x_raton=ent.x.cx >> 1; + ent.x.dx = 100; + y_raton=ent.x.dx; + int86(0x33, &ent, &sal); /* fija la posicin del ratn */ + + ent.x.ax = 1; + int86(0x33, &ent, &sal); /* muestra el puntero del ratn */ +} + +void activa_raton(void) +{ + union REGS ent, sal; + + ent.x.ax = 1; + int86(0x33, &ent, &sal); +} + +void desactiva_raton(void) +{ + union REGS ent, sal; + + ent.x.ax = 2; + int86(0x33, &ent, &sal); +} + +void espera_pulsar(void) +{ + union REGS ent, sal; + + do{ + if(bioskey(1)!=0) break; + ent.x.ax = 3; + int86(0x33, &ent, &sal); /* lee posicin y estados del botn */ + }while((sal.x.bx & 3)==0); + boton_izq=sal.x.bx & 1; + boton_der=(sal.x.bx >> 1) & 1; + x_raton=sal.x.cx >> 1; + y_raton=sal.x.dx; +} + +void espera_soltar(void) +{ + union REGS ent, sal; + + do{ + ent.x.ax = 3; + int86(0x33, &ent, &sal); /* lee posicin y estados del botn */ + }while((sal.x.bx & 3)!=0); + boton_izq=sal.x.bx & 1; + boton_der=(sal.x.bx >> 1) & 1; + x_raton=sal.x.cx >> 1; + y_raton=sal.x.dx; +} + +void no_hay_raton(void) +{ + asigna_modo_video(ALFANUMERICO); + libera_memoria(); + gotoxy(1,1); printf("No hay RATON instalado"); + exit(0); +} + +void salir_al_dos(void) +{ + asigna_modo_video(ALFANUMERICO); + libera_memoria(); + exit(0); +} + +void asigna_memoria(void) +{ + if((dir_zona_pantalla = malloc (64000))==NULL) { + printf("No hay suficiente memoria. Libere programas residentes."); + exit(1); + } + if((dir_carga_dibujos = malloc (65000))==NULL) { + printf("No hay suficiente memoria. Libere programas residentes."); + exit(1); + } + if((dir_dibujo1 = malloc (64000))==NULL) { + printf("No hay suficiente memoria. Libere programas residentes."); + exit(1); + } + if((dir_dibujo2 = malloc (64000))==NULL) { + printf("No hay suficiente memoria. Libere programas residentes."); + exit(1); + } +} + +void libera_memoria(void) +{ + free(dir_zona_pantalla); + free(dir_carga_dibujos); + free(dir_dibujo1); + free(dir_dibujo2); +} + +void asigna_modo_video(char modo) /* asigna el modo de vdeo indicado */ +{ /* en la variable "modo" */ + union REGS ent, sal; + + ent.h.al = modo; + ent.h.ah = 0; + int86(16, &ent, &sal); /* funcin para asignar el modo de video */ +} + +void lee_dibujos(char *fichero) +{ + char *p; + + if((handle_dibujos = fopen(fichero, "rb"))==NULL) { + printf("No se puede abrir el archivo."); + exit(1); + } + p=dir_carga_dibujos; + while(!feof(handle_dibujos)) { + *p++=getc(handle_dibujos); + } + if(fclose(handle_dibujos)!=NULL) { + printf("No se puede cerrar el archivo."); + exit(1); + } +} + +void descomprime_dibujo(char *dir_escritura) +{ + unsigned char byte; + char *dir_lectura; + int columnas, filas, contador; + + dir_lectura=dir_carga_dibujos+128; /* inicio del dibujo comprimido */ + + for(filas=200; filas>0; filas--) { + columnas=320; + dir_escritura-=columnas; dir_escritura+=320; + while(columnas>0) { + byte=(unsigned)*dir_lectura++; + if(byte<=192) { *dir_escritura++=byte; columnas--; } + else { + contador=byte&63; byte=*dir_lectura++; + for(;contador>0;contador--) { *dir_escritura++=byte;columnas--; } + } + } + } + dir_lectura++; + asigna_rgb(dir_lectura); /* remapea los 256 colores del dibujo */ +} + +void asigna_rgb(char *dir_lectura) +{ + struct SREGS seg; + union REGS ent, sal; + unsigned int reg_dx, n; + long int dir; + char *dir_col; + + dir_col=dir_lectura; /* divide entre */ + for(n=256*3; n>0; n--) { /* 4 los colores */ + *dir_col=*dir_col >> 2; dir_col++; + } + + reg_dx=(int)dir_lectura; /* offset de los colores */ + dir =(long)dir_lectura; /* obtiene el segmento */ + seg.es=(int)(dir >> 16); /* donde estan los colores */ + + ent.h.al = 18; + ent.h.ah = 16; + ent.x.bx = 0; + ent.x.cx = 256; + ent.x.dx = reg_dx; + int86x(0x10, &ent, &sal, &seg); /* funcin para asignar los colores */ +} + +void cinta_cine(void) +{ + textcolor(color_izq); + gotoxy(21, 1); cprintf (" "); + gotoxy(19, 2); cprintf (" "); + gotoxy(17, 3); cprintf (" "); + gotoxy(15, 4); cprintf (" "); + gotoxy(13, 5); cprintf (" "); + gotoxy(11, 6); cprintf (" "); + gotoxy( 9, 7); cprintf (" "); + gotoxy( 7, 8); cprintf (" "); + gotoxy( 5, 9); cprintf (" "); + gotoxy( 3,10); cprintf (" "); + gotoxy( 1,11); cprintf(" "); + gotoxy( 1,12); cprintf(" "); + gotoxy( 1,13); cprintf(" "); + gotoxy( 1,14); cprintf(" "); + gotoxy( 1,15); cprintf(" "); + gotoxy( 1,16); cprintf(""); + gotoxy( 1,17); cprintf(""); + gotoxy( 1,18); cprintf(""); + + textcolor(color_der); + gotoxy(79,14); cprintf (" "); + gotoxy(77,15); cprintf (""); + gotoxy(75,16); cprintf (""); + gotoxy(73,17); cprintf (" "); + gotoxy(71,18); cprintf (" "); + gotoxy(69,19); cprintf (" "); + gotoxy(67,20); cprintf (" "); + gotoxy(65,21); cprintf (" "); + gotoxy(63,22); cprintf (" "); + gotoxy(61,23); cprintf (" "); + gotoxy(59,24); cprintf (" "); + gotoxy(57,25); cprintf(" "); +} + +void pantalla_cine(void) +{ + textbackground(BLACK); textcolor(BLACK); clrscr(); + textcolor(BLUE); + gotoxy( 1, 1); cprintf(" "); + gotoxy( 1, 2); cprintf(" "); + gotoxy( 1, 3); cprintf(" "); + gotoxy( 1, 4); cprintf(" "); + gotoxy( 1, 5); cprintf(" "); + gotoxy( 1, 6); cprintf(" "); + gotoxy( 1, 7); cprintf(" "); + gotoxy( 1, 8); cprintf(" "); + gotoxy( 1, 9); cprintf(" "); + gotoxy( 1,10); cprintf(" "); + gotoxy( 1,11); cprintf(" "); + gotoxy( 1,12); cprintf(" "); + gotoxy( 1,13); cprintf(" "); + gotoxy( 1,14); cprintf(" "); + gotoxy( 1,15); cprintf(" "); + gotoxy( 1,16); cprintf(" "); + gotoxy( 1,17); cprintf(" "); + gotoxy( 1,18); cprintf(" "); + gotoxy( 1,19); cprintf(" "); + + textcolor(BLUE); + gotoxy(54,12); cprintf(" "); + gotoxy(54,13); cprintf(" "); + gotoxy(54,14); cprintf(" "); + gotoxy(54,15); cprintf(" "); + gotoxy(54,16); cprintf(" "); + gotoxy(54,17); cprintf(" "); + gotoxy(54,18); cprintf(" "); + gotoxy(54,19); cprintf(" "); + gotoxy(54,20); cprintf(" "); + gotoxy(54,21); cprintf(" "); + gotoxy(54,22); cprintf(" "); + gotoxy(54,23); cprintf(" "); + gotoxy(54,24); cprintf(" "); + gotoxy(54,25); cprintf(" "); +} + +void premios(void) +{ + textcolor(WHITE); + gotoxy(49, 1); cprintf("LXVI EDICION DE LOS OSCARS"); + + textcolor(YELLOW); + gotoxy(45, 3); cprintf("MEJOR PELICULA "); + gotoxy(43, 4); cprintf("MEJOR DIRECTOR "); + gotoxy(41, 5); cprintf("MEJOR ACTRIZ "); + gotoxy(39, 6); cprintf("MEJOR ACTOR "); + gotoxy(37, 7); cprintf("MEJOR ACTRIZ SECUNDARIA "); + gotoxy(35, 8); cprintf("MEJOR ACTOR SECUNDARIO "); + gotoxy(33, 9); cprintf("MEJOR PELICULA EXTRANJERA "); + gotoxy(31,10); cprintf("MEJOR GUION ORIGINAL "); + gotoxy(29,11); cprintf("MEJOR GUION ADAPTADO "); + gotoxy(27,12); cprintf("MEJOR DIRECCION ARTISTICA "); + gotoxy(25,13); cprintf("MEJOR SONIDO "); + gotoxy(23,14); cprintf("MEJOR MONTAJE "); + gotoxy(21,15); cprintf("MEJOR FOTOGRAFIA "); + gotoxy(19,16); cprintf("MEJOR EFECTOS DE SONIDO "); + gotoxy(17,17); cprintf("MEJOR MUSICA ORIGINAL "); + gotoxy(15,18); cprintf("MEJOR CANCION "); + gotoxy(13,19); cprintf("MEJOR VESTUARIO "); + gotoxy(11,20); cprintf("MEJOR EFECTOS VISUALES "); + gotoxy( 9,21); cprintf("MEJOR MAQUILLAJE "); + gotoxy( 7,22); cprintf("MEJOR CORTO DE ANIMACION "); + gotoxy( 5,23); cprintf("MEJOR CORTO DE ACCION EN VIVO "); + gotoxy( 3,24); cprintf("MEJOR LARGOMETRAJE DOCUMENTAL "); + gotoxy( 1,25); cprintf("MEJOR CORTO DOCUMENTAL "); +} + +void premiados(void) +{ + textcolor(WHITE); + switch(y_raton/8) { + case 2: gotoxy(45, 3); cprintf("La lista de Schindler "); break; + case 3: gotoxy(43, 4); cprintf("Spielberg, La lista de Schindler "); break; + case 4: gotoxy(41, 5); cprintf("Holly Hunter, El Piano "); break; + case 5: gotoxy(39, 6); cprintf("Tom Hanks, Philadelphia "); break; + case 6: gotoxy(37, 7); cprintf("Anna Paquin, El Piano "); break; + case 7: gotoxy(35, 8); cprintf("Tommy Lee Jones, El Fugitivo "); break; + case 8: gotoxy(33, 9); cprintf("Belle poque (Espaa), Fernando Trueba "); break; + case 9: gotoxy(31,10); cprintf("Jane Campion, El Piano "); break; + case 10: gotoxy(29,11); cprintf("Steven Zaillian, La lista de Schindler "); break; + case 11: gotoxy(27,12); cprintf("Allan Starski y Ewa Braun, La lista de Schindler "); break; + case 12: gotoxy(25,13); cprintf("Parque Jursico "); break; + case 13: gotoxy(23,14); cprintf("Michael Kahn, La lista de Schindler "); break; + case 14: gotoxy(21,15); cprintf("Janusz Kaminski, La lista de Schindler "); break; + case 15: gotoxy(19,16); cprintf("Parque Jursico "); break; + case 16: gotoxy(17,17); cprintf("John Williams, La lista de Schindler "); break; + case 17: gotoxy(15,18); cprintf("Streets of Philadelphia, Bruce Springsteen "); break; + case 18: gotoxy(13,19); cprintf("Gabriella Pescucci, La edad de la inocencia "); break; + case 19: gotoxy(11,20); cprintf("Parque Jursico "); break; + case 20: gotoxy( 9,21); cprintf("Sra. Doubtfire "); break; + case 21: gotoxy( 7,22); cprintf("The wrong trousers "); break; + case 22: gotoxy( 5,23); cprintf("Schwarzfahrer "); break; + case 23: gotoxy( 3,24); cprintf("I am a promise:child. of Stanton Elementary School"); break; + case 24: gotoxy( 1,25); cprintf("Defending our lives "); break; + } +} + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..1be9a9b --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +#EPROM +*11/11/1991* +ToDo: wwtcf? + +![screenshot](/EPROM.png "Screenshot")