EPROM/EPROM-II.CPP
2021-09-08 21:04:26 +02:00

2119 lines
58 KiB
C++
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

///////////////////////
/// JD. ///
/// ///
/// ùFuTuRe ViSiOnù ///
//////////////////////////////////////////////////////////////////////////////
/// Nombre: Eprom-II.CPP ///
/// Modulo: Principal ///
/// Descripci¢n: Programador de Eprom's con ampliaci¢n del numero ///
/// disponible de las mismas sin necesidad de ///
/// recompilar nada. ///
/// ///
/// Autor: Jos David Guilln Dominguez ///
/// Fecha: XX - XX - 1995 ///
/// ///
/// Comentario: -- Primera utilizaci¢n de mi libreria ( v. BETA ) ///
/// con proposito de aplicaci¢n final. ///
/// ///
/// Compilador Borland C++ 3.0 ///
//////////////////////////////////////////////////////////////////////////////
//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ Librerias ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
#include <graphics.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <alloc.h>
#include <stdio.h>
#include <ctype.h>
#include <math.h>
#include <dos.h>
#include <dir.h>
#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 Gr fico
Menu_de_Edicion(); // Inicializa la Edici¢n
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 --> A¥ADIR
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;
// ReP g
case 73:
// CurrRow = 1;
if( CurrTopLineEprom > /*28*/25 ) { CurrTopLineEprom -= /*28*/25; } else { CurrTopLineEprom = 1; }
if( CurrTopLineEprom < 1 ) { CurrTopLineEprom = 1; }
PrintWholeScreenEprom();
GetLineEprom();
EditCursorEprom(0);
break;
// AvP g
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;
// Direcci¢n 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 dise¤ado 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 dise¤ada para la introducion lineal de caracteres Gr ficos
//////// 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 dise¤ada para la introducion lineal de caracteres Gr ficos
//////// 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 tama¤o Û
//ÛÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÛ
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)<N_Eprom ) {
if(CurrRowCE == 12) { CurrTopLineCE ++; PrintEprom_CE_WholeScreen(CurrTopLineCE); }
else CurrRowCE++;
}
break;
default:
break;
}
}
}while(!acabar);
Imprime_Estaticos( 2, "Eprom.JDf" ); // Imprime Textos ( 1 ), secuencia 1
Imprime_Eprom_Actual();
Fuente( 2, 6 );
PrintWholeScreenEprom();
GetLineEprom();
EditCursorEprom(0);
}
//ÛßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÛ
//Û Imprime todas las eproms cargadas Û
//ÛÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÛ
void PrintEprom_CE_WholeScreen(int tmp){
char buffer[80];
bar( 177, 197, 463, 323);
int TP, FI, NP, DM, BD;
int CurrRowCE;
for(CurrRowCE = 1; CurrRowCE < (12+1); CurrRowCE++)
if ( (tmp + CurrRowCE ) <= N_Eprom ) {
TP = S_Eprom[tmp + CurrRowCE - 1].TP;
FI = S_Eprom[tmp + CurrRowCE - 1].FI;
NP = S_Eprom[tmp + CurrRowCE - 1].NP;
DM = S_Eprom[tmp + CurrRowCE - 1].DM;
BD = S_Eprom[tmp + CurrRowCE - 1].BD;
sprintf(buffer, " % 2d % 3d % 3d % 3d % 3d % 11ld %s",TP, FI, NP, DM, BD, S_Eprom[tmp + CurrRowCE - 1].ID, S_Eprom[tmp + CurrRowCE - 1].ID_TEXT );
outtextxy( 176, ( 200 + (CurrRowCE - 1)*10), buffer);
}
}
//ÛßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÛ
//Û Realce para las eproms seleccionadas Û
//Û con el cursor... Û
//ÛÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÛ
void EditCursorEprom_CE(int SH, int CurrRowCE, int CurrTopLineCE){
int TP = S_Eprom[CurrTopLineCE + CurrRowCE - 1].TP;
int FI = S_Eprom[CurrTopLineCE + CurrRowCE - 1].FI;
int NP = S_Eprom[CurrTopLineCE + CurrRowCE - 1].NP;
int DM = S_Eprom[CurrTopLineCE + CurrRowCE - 1].DM;
int BD = S_Eprom[CurrTopLineCE + CurrRowCE - 1].BD;
char buffer[80];
if (!SH) { setcolor(63); setfillstyle(SOLID_FILL, 63); }
else
{ setcolor(0); setfillstyle(SOLID_FILL, 0); }
bar( 178, 200+ ( CurrRowCE-1 )*10 + 2, 458, 200 + ( CurrRowCE - 1 )*10+10 );
if(!SH) setcolor(0); else Texto_Normal
sprintf(buffer, " % 3d % 3d % 3d % 3d % 3d % 11ld %s",TP, FI, NP, DM, BD, S_Eprom[CurrTopLineCE + CurrRowCE - 1].ID, S_Eprom[CurrTopLineCE + CurrRowCE - 1].ID_TEXT );
outtextxy( 176, ( 200 + (CurrRowCE - 1)*10), buffer);
}
//ÛßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÛ
//Û Manda el programa de Û
//Û DISCO ---> 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 c¢digo 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 tensi¢n es incorrecta, no programa
}
cont = 0;
longitud = 0;
Carga_Cien_Elementos(Eprom2);
for(int i=0; i<Eprom1_inx.Fin; i++) {
// Tension
outport( 0x303, TP );
// Direcci¢n
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 );
cont++; if(cont>100) {
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 );
// Direcci¢n
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;
// Direcci¢n 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)], "<SinTitulo>");
}
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 se¤alados 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 versi¢n 1.1 Û
//ÛÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÛ
int LeeCabecera(char *fichero){
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ//
//Û Comprueba apertura correcta de Indice, y Datos y creaci¢n... Û//
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß//
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 gesti¢n de la Û//
//Û rectificaci¢n al paso. ( Direcci¢n --> 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 gesti¢n de la Û
//Û rectificaci¢n al paso. ( Direcci¢n --> 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, "Direcci¢n ( HEXADECIMAL ) ");
break;
case 2:
sprintf(Buffer, "% 15lu", Eprom1.Direccion);
outtextxy( x+4, (y+2)+(CurrRowEprom1-1)*15, Buffer );
outtextxy( 15, 455, "Direcci¢n ( 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 visualizaci¢n. Û
//ÛÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÛ
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 versi¢n 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 versi¢n 1.1 Û
//ÛÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÛ
int Abre_Ficha_Eprom(void){
CurrRowEprom1 = 1;
CurrTopLineEprom = 1;
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ//
//Û Comprueba apertura correcta de Indice, y Datos y creaci¢n... Û//
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß//
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 ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
//Û Û
//Û A¤ade 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 pulsaci¢n 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);
}
}
}