759 lines
22 KiB
C++
759 lines
22 KiB
C++
#define SEC_OPTAR 2
|
||
#define ENCUADRE 3
|
||
|
||
#include <math.h>
|
||
|
||
#include <io.h>
|
||
#include <dos.h>
|
||
#include <time.h>
|
||
#include <stdio.h>
|
||
#include <conio.h>
|
||
#include <alloc.h>
|
||
#include <string.h>
|
||
#include <stdlib.h>
|
||
#include <graphics.h>
|
||
|
||
#include "..\libs\make_bot\make_bot.h" // Fuciones de MAKE_BOTON
|
||
|
||
#define PULSO_QUE_CABEN 48
|
||
#define ANCHO_PULSO 12
|
||
#define ALTO_PULSO 12
|
||
extern void ponicono(int x,int y,char matriz[18][18], char pos);
|
||
extern char flecha [18] [18];
|
||
|
||
typedef struct
|
||
{
|
||
int x, y; // Coordenadas iniciales de muestreo
|
||
char ndigitos; // n£mero de digitos a mostrar
|
||
char AX, AY; // factor de espaciado
|
||
char C1, C2, C3; // colores de fondo, texto, borde
|
||
|
||
// Datos privados y uso interno exclusivamente
|
||
unsigned int Flen; // longitud de la frase actual
|
||
char BitByte; // bit del byte por el que va en el recorrido
|
||
char currByte; // byte actual dentro de la frase
|
||
} p_Ampliada;
|
||
|
||
#define OFF 0
|
||
#define ON 1
|
||
|
||
#ifdef __cplusplus
|
||
#define __CPPARGS ...
|
||
#else
|
||
#define __CPPARGS
|
||
#endif
|
||
#define INTR 0X1C /* The clock tick interrupt */
|
||
|
||
char count = 0, intvect = OFF, IntVect = OFF;
|
||
|
||
extern int Optar( int optar, ...);
|
||
|
||
void AnulaInterrupcion(void);
|
||
void interrupt handler(__CPPARGS);
|
||
void interrupt ( *oldhandler)(__CPPARGS);
|
||
char *ptr_char;
|
||
|
||
void DibujaPulsos( long comienzo, char bit, char far *Datos, int x, int y, char color, long TotalPulsos );
|
||
void LeeFuentes(char *file);
|
||
void Fuente_Amplia( char *Frase, p_Ampliada far *FA );
|
||
void DibujaFondo(void);
|
||
void DibujaSeparadores( int X1, int Y1, int X2, int Y2, char color );
|
||
|
||
void Error( int code, char *MensajeError );
|
||
|
||
void BorraPantalla(void);
|
||
void ComienzaRutina(void);
|
||
|
||
extern char file_browser( char *comodin_name, char *texto1, char Cargar_Salvar );
|
||
|
||
long InicioPulso[6][2];
|
||
|
||
void CargarOnda( char *file, char far *Datos, char Ventana );
|
||
void SalvarOnda( char *file, char far *Datos, char Ventana );
|
||
|
||
char far *Datos[2];
|
||
|
||
int TiempoEspera = 5, DIR_LPT = 0x378, ANGULO = 0;
|
||
|
||
int main( int argc, char *argv[] )
|
||
{
|
||
|
||
int i;
|
||
long j;
|
||
char buffer[4][80] = { "Jos‚ David Guill‚n || _-ùFuTuRe ViSiOnù-_ || 1996 (c)",
|
||
" ",
|
||
" e-mail: Jose-David.Guillen@cs.us.es ",
|
||
" " };
|
||
|
||
if ( argc == 2 )
|
||
{
|
||
TiempoEspera = atoi(argv[1]);
|
||
if ( TiempoEspera < 0 || TiempoEspera > 1000 )
|
||
TiempoEspera = 5;
|
||
}
|
||
if ( argc == 3 )
|
||
{
|
||
DIR_LPT = atoi( argv[2] );
|
||
if ( DIR_LPT < 0 )
|
||
DIR_LPT = 0x379;
|
||
|
||
}
|
||
if ( argc == 4 )
|
||
{
|
||
ANGULO = atoi( argv[3] );
|
||
if ( ANGULO < 0 )
|
||
ANGULO = 0;
|
||
|
||
}
|
||
|
||
|
||
if ( atexit( AnulaInterrupcion ) != 0 )
|
||
intvect = OFF;
|
||
else
|
||
intvect = ON;
|
||
|
||
True_Push = ON; PunteroRaton = 1;
|
||
Initialize( 9, 2 ); // Inicializa el Modo Gr fico
|
||
inicializa_raton_grafico( 0, 0, 639, 479 );
|
||
setrgbpalette(EGA_WHITE, 56, 58, 59 );
|
||
setrgbpalette(EGA_LIGHTGRAY, 30, 37, 43 );
|
||
setrgbpalette(EGA_DARKGRAY, 24, 27, 30 );
|
||
|
||
if ( carga_botones( "llave.img" ) != OK ) Error( 0x03, "Make Boton, no pudo cargar los botones" );
|
||
|
||
if ( ( Datos[0] = (char far *)farcalloc( 100000, sizeof(char) ) ) == NULL )
|
||
{
|
||
Optar( 0, "ERROR DE MEMORIA", "Memoria insuficiente", "para la primera forma", "de onda.", NULL );
|
||
closegraph();
|
||
return -1;
|
||
}
|
||
|
||
if ( ( Datos[1] = (char far *)farcalloc( 100000, sizeof(char) ) ) == NULL )
|
||
{
|
||
farfree( Datos[0] );
|
||
Optar( 0, "ERROR DE MEMORIA", "Memoria insuficiente", "para la segunda forma", "de onda.", NULL );
|
||
closegraph();
|
||
return -1;
|
||
}
|
||
|
||
_fmemcpy( Datos[0], &i, 50000 );
|
||
|
||
if ( intvect == ON )
|
||
{
|
||
// save the old interrupt vector
|
||
oldhandler = getvect(INTR);
|
||
// install the new interrupt handler
|
||
setvect(INTR, handler);
|
||
|
||
IntVect = ON;
|
||
}
|
||
|
||
if ( ( ptr_char = ( char *)malloc( sizeof(char)*4096 ) ) == NULL )
|
||
Error( 0x06, "Error inicializando Memoria, fuentes" );
|
||
LeeFuentes("llave.fnt");
|
||
|
||
|
||
DibujaFondo();
|
||
|
||
ComienzaRutina();
|
||
|
||
BorraPantalla();
|
||
|
||
free( ptr_char );
|
||
AnulaInterrupcion();
|
||
|
||
closegraph();
|
||
|
||
printf( "\n%s", buffer[0] );
|
||
printf( "\n%s", buffer[1] );
|
||
printf( "\n%s", buffer[2] );
|
||
printf( "\n%s", buffer[3] );
|
||
|
||
farfree( Datos[0] );
|
||
farfree( Datos[1] );
|
||
return 0;
|
||
|
||
}
|
||
|
||
void ComienzaRutina(void)
|
||
{
|
||
int ok, BPush, VentanaActiva, i, j;
|
||
long DLectura;
|
||
char buffer[280];
|
||
|
||
// Temporal hasta que existan datos reales...
|
||
/*
|
||
Datos[0] = (char *)&ok;
|
||
Datos[1] = (char *)&ok;
|
||
*/
|
||
|
||
|
||
VentanaActiva = 0;
|
||
for ( j = 0; j < 2; j++ )
|
||
for ( i = 0; i < 5; i++ )
|
||
InicioPulso[i][j] = 0;
|
||
|
||
InicioPulso[5][0] = 100000;
|
||
InicioPulso[5][1] = 100000;
|
||
|
||
DibujaSeparadores( 63, 27, 630, 193, EGA_RED );
|
||
DibujaSeparadores( 63, 27 + 250, 630, 193 + 250, EGA_RED );
|
||
// Borramos los pulsos anteriores, y los desplazamos
|
||
for ( j = 0; j < 5; j ++ )
|
||
{
|
||
DibujaPulsos( InicioPulso[j][0], 0x01 << j, Datos[0], 63, 42 + 30*j + 0, EGA_GREEN, InicioPulso[5][0] );
|
||
DibujaPulsos( InicioPulso[j][1], 0x01 << j, Datos[1], 63, 42 + 30*j + 250, EGA_GREEN, InicioPulso[5][1] );
|
||
}
|
||
|
||
// Flecha hacia arriba
|
||
ponicono( 20, 225, flecha, 2 );
|
||
|
||
|
||
ok = 0;
|
||
do {
|
||
|
||
// Actualiza todos los puntos
|
||
setfillstyle( SOLID_FILL, EGA_BLACK );
|
||
setcolor( EGA_WHITE );
|
||
for ( i = 0; i < 2; i++ )
|
||
for ( j = 0; j < 5; j++ )
|
||
{
|
||
bar( 12, 42+31*j + 250*i, 52, 53+31*j + 250*i );
|
||
sprintf( buffer, "%7ld", InicioPulso[j][i] );
|
||
outtextxy( 12, 41 + 31*j + 250*i, buffer );
|
||
}
|
||
|
||
BPush = Comprueba_Secuencia( 1, NULL );
|
||
|
||
switch( BPush )
|
||
{
|
||
case -2:
|
||
case -1:
|
||
case -0:
|
||
while( kbhit() ) getch();
|
||
break;
|
||
// Salir
|
||
case 1:
|
||
ok = 1;
|
||
break;
|
||
// Cambio de Ventana
|
||
case 2:
|
||
VentanaActiva = !VentanaActiva;
|
||
// Flecha hacia arriba
|
||
ponicono( 20, 225, flecha, VentanaActiva == 0 ? 2 : 4 );
|
||
|
||
break;
|
||
// Desplazamiento de ondas (IZQUIERDA )
|
||
case 3:
|
||
case 4:
|
||
case 5:
|
||
case 6:
|
||
case 7:
|
||
InicioPulso[BPush-3][VentanaActiva] --;
|
||
if ( InicioPulso[BPush-3][VentanaActiva] < 0 )
|
||
{
|
||
InicioPulso[BPush-3][VentanaActiva] = 0;
|
||
} else {
|
||
// Borramos la onda anterior
|
||
DibujaPulsos( InicioPulso[BPush-3][VentanaActiva] + 1, 0x01 << (BPush - 3), Datos[VentanaActiva], 63, 42 + 30*(BPush-3) + ( VentanaActiva ? 250 : 0 ), EGA_BLACK, InicioPulso[5][VentanaActiva] );
|
||
|
||
// Dibujamos la nueva onda
|
||
DibujaPulsos( InicioPulso[BPush-3][VentanaActiva], 0x01 << (BPush - 3), Datos[VentanaActiva], 63, 42 + 30*(BPush-3) + ( VentanaActiva ? 250 : 0 ), EGA_GREEN, InicioPulso[5][VentanaActiva] );
|
||
}
|
||
break;
|
||
// Desplazamiento de ondas (DERECHA)
|
||
case 8:
|
||
case 9:
|
||
case 10:
|
||
case 11:
|
||
case 12:
|
||
InicioPulso[BPush-8][VentanaActiva] ++;
|
||
if ( InicioPulso[BPush-8][VentanaActiva] > InicioPulso[5][VentanaActiva] )
|
||
{
|
||
InicioPulso[BPush-8][VentanaActiva] --;
|
||
} else {
|
||
// Borramos la onda anterior
|
||
DibujaPulsos( InicioPulso[BPush-8][VentanaActiva] - 1, 0x01 << (BPush - 8), Datos[VentanaActiva], 63, 42 + 30*(BPush-8) + (VentanaActiva ? 250 : 0), EGA_BLACK, InicioPulso[5][VentanaActiva] );
|
||
|
||
// Dibujamos la nueva onda
|
||
DibujaPulsos( InicioPulso[BPush-8][VentanaActiva], 0x01 << (BPush - 8), Datos[VentanaActiva], 63, 42 + 30*(BPush-8) + (VentanaActiva ? 250 : 0), EGA_GREEN, InicioPulso[5][VentanaActiva] );
|
||
}
|
||
break;
|
||
// Desplazamiento de pulsos TODAS (IZQUIERDA)
|
||
case 13:
|
||
// Borramos los pulsos anteriores, y los desplazamos
|
||
for ( j = 0; j < 5; j ++ )
|
||
{
|
||
DibujaPulsos( InicioPulso[j][VentanaActiva], 0x01 << j, Datos[VentanaActiva], 63, 42 + 30*j + ( VentanaActiva ? 250 : 0 ), EGA_BLACK, InicioPulso[5][VentanaActiva] );
|
||
InicioPulso[j][VentanaActiva]--;
|
||
if ( InicioPulso[j][VentanaActiva] < 0 )
|
||
InicioPulso[j][VentanaActiva] = 0;
|
||
}
|
||
|
||
DibujaSeparadores( 63, 27 + (VentanaActiva ? 250 : 0 ), 630, 193 + (VentanaActiva ? 250 : 0 ), EGA_RED );
|
||
|
||
// Dibujamos los nuevos pulsos.
|
||
for ( j = 0; j < 5; j ++ )
|
||
DibujaPulsos( InicioPulso[j][VentanaActiva], 0x01 << j, Datos[VentanaActiva], 63, 42 + 30*j + ( VentanaActiva ? 250 : 0 ), EGA_GREEN, InicioPulso[5][VentanaActiva] );
|
||
break;
|
||
// Reset de todos los pulsos
|
||
case 14:
|
||
// Borramos los pulsos anteriores, y los reseteamos
|
||
for ( j = 0; j < 5; j ++ )
|
||
{
|
||
DibujaPulsos( InicioPulso[j][VentanaActiva], 0x01 << j, Datos[VentanaActiva], 63, 42 + 30*j + ( VentanaActiva ? 250 : 0 ), EGA_BLACK, InicioPulso[5][VentanaActiva] );
|
||
InicioPulso[j][VentanaActiva] = 0;
|
||
}
|
||
|
||
DibujaSeparadores( 63, 27 + (VentanaActiva ? 250 : 0 ), 630, 193 + (VentanaActiva ? 250 : 0 ), EGA_RED );
|
||
|
||
// Dibujamos los nuevos pulsos.
|
||
for ( j = 0; j < 5; j ++ )
|
||
DibujaPulsos( InicioPulso[j][VentanaActiva], 0x01 << j, Datos[VentanaActiva], 63, 42 + 30*j + ( VentanaActiva ? 250 : 0 ), EGA_GREEN, InicioPulso[5][VentanaActiva] );
|
||
break;
|
||
// Al final de todos los pulso
|
||
case 15:
|
||
// Borramos los pulsos anteriores, nos colocamos al final
|
||
for ( j = 0; j < 5; j ++ )
|
||
{
|
||
DibujaPulsos( InicioPulso[j][VentanaActiva], 0x01 << j, Datos[VentanaActiva], 63, 42 + 30*j + ( VentanaActiva ? 250 : 0 ), EGA_BLACK, InicioPulso[5][VentanaActiva] );
|
||
InicioPulso[j][VentanaActiva] = InicioPulso[5][VentanaActiva] - PULSO_QUE_CABEN;
|
||
}
|
||
|
||
DibujaSeparadores( 63, 27 + (VentanaActiva ? 250 : 0 ), 630, 193 + (VentanaActiva ? 250 : 0 ), EGA_RED );
|
||
|
||
// Dibujamos los nuevos pulsos.
|
||
for ( j = 0; j < 5; j ++ )
|
||
DibujaPulsos( InicioPulso[j][VentanaActiva], 0x01 << j, Datos[VentanaActiva], 63, 42 + 30*j + ( VentanaActiva ? 250 : 0 ), EGA_GREEN, InicioPulso[5][VentanaActiva] );
|
||
break;
|
||
// Desplazamiento de pulsoso TODOS (Derecha)
|
||
case 16:
|
||
// Borramos los pulsos anteriores, y los desplazamos
|
||
for ( j = 0; j < 5; j ++ )
|
||
{
|
||
DibujaPulsos( InicioPulso[j][VentanaActiva], 0x01 << j, Datos[VentanaActiva], 63, 42 + 30*j + ( VentanaActiva ? 250 : 0 ), EGA_BLACK, InicioPulso[5][VentanaActiva] );
|
||
InicioPulso[j][VentanaActiva]++;
|
||
if ( InicioPulso[j][VentanaActiva] > InicioPulso[5][VentanaActiva] )
|
||
InicioPulso[j][VentanaActiva]--;
|
||
}
|
||
|
||
DibujaSeparadores( 63, 27 + (VentanaActiva ? 250 : 0 ), 630, 193 + (VentanaActiva ? 250 : 0 ), EGA_RED );
|
||
|
||
// Dibujamos los nuevos pulsos.
|
||
for ( j = 0; j < 5; j ++ )
|
||
DibujaPulsos( InicioPulso[j][VentanaActiva], 0x01 << j, Datos[VentanaActiva], 63, 42 + 30*j + ( VentanaActiva ? 250 : 0 ), EGA_GREEN, InicioPulso[5][VentanaActiva] );
|
||
break;
|
||
// CARGAR
|
||
case 17:
|
||
for ( j = 0; j < 5; j ++ )
|
||
{
|
||
DibujaPulsos( InicioPulso[j][0], 0x01 << j, Datos[0], 63, 42 + 30*j + 0, EGA_BLACK, InicioPulso[5][0] );
|
||
DibujaPulsos( InicioPulso[j][1], 0x01 << j, Datos[1], 63, 42 + 30*j + 250, EGA_BLACK, InicioPulso[5][1] );
|
||
}
|
||
|
||
strcpy( buffer, "*.llv" );
|
||
if ( file_browser( buffer, "Cargar Archivo", 0 ) )
|
||
CargarOnda( buffer, Datos[VentanaActiva], VentanaActiva );
|
||
|
||
DibujaSeparadores( 63, 27, 630, 193, EGA_RED );
|
||
DibujaSeparadores( 63, 27 + 250, 630, 193 + 250, EGA_RED );
|
||
for ( j = 0; j < 5; j ++ )
|
||
{
|
||
DibujaPulsos( InicioPulso[j][0], 0x01 << j, Datos[0], 63, 42 + 30*j + 0, EGA_BLACK, InicioPulso[5][0] );
|
||
DibujaPulsos( InicioPulso[j][1], 0x01 << j, Datos[1], 63, 42 + 30*j + 250, EGA_BLACK, InicioPulso[5][1] );
|
||
}
|
||
break;
|
||
// SALVAR
|
||
case 18:
|
||
strcpy( buffer, "*.llv" );
|
||
if ( file_browser( buffer, "Salvar Archivo", 1 ) )
|
||
SalvarOnda( buffer, Datos[VentanaActiva], VentanaActiva );
|
||
break;
|
||
// LEER ONDA
|
||
case 19:
|
||
for ( j = 0; j < 5; j ++ )
|
||
{
|
||
DibujaPulsos( InicioPulso[j][0], 0x01 << j, Datos[0], 63, 42 + 30*j + 0, EGA_BLACK, InicioPulso[5][0] );
|
||
DibujaPulsos( InicioPulso[j][1], 0x01 << j, Datos[1], 63, 42 + 30*j + 250, EGA_BLACK, InicioPulso[5][1] );
|
||
}
|
||
Optar( 0, "Lectura de Onda", "Prepare el chisme, y", "pulse una tecla cuando este", "preparado...", NULL );
|
||
Optar( ENCUADRE, "Leyendo Onda", "Presione una cualquier", "tecla para interrumpir el", "proceso...", NULL );
|
||
|
||
outportb( DIR_LPT + 0, 0xFF );
|
||
outportb( DIR_LPT + 1, 0x01 );
|
||
// Comienza lectura
|
||
for ( DLectura=0; DLectura < InicioPulso[5][VentanaActiva] && !kbhit(); DLectura++ )
|
||
{
|
||
Datos[VentanaActiva][DLectura] = inportb( DIR_LPT );
|
||
|
||
sin( ANGULO );
|
||
delay(TiempoEspera);
|
||
}
|
||
|
||
while( kbhit() ) getch();
|
||
|
||
Optar( ENCUADRE, NULL );
|
||
DibujaSeparadores( 63, 27, 630, 193, EGA_RED );
|
||
DibujaSeparadores( 63, 27 + 250, 630, 193 + 250, EGA_RED );
|
||
// Borramos los pulsos anteriores, y los desplazamos
|
||
for ( j = 0; j < 5; j ++ )
|
||
{
|
||
DibujaPulsos( InicioPulso[j][0], 0x01 << j, Datos[0], 63, 42 + 30*j + 0, EGA_GREEN, InicioPulso[5][0] );
|
||
DibujaPulsos( InicioPulso[j][1], 0x01 << j, Datos[1], 63, 42 + 30*j + 250, EGA_GREEN, InicioPulso[5][1] );
|
||
}
|
||
break;
|
||
|
||
}
|
||
|
||
}while ( !ok );
|
||
|
||
}
|
||
|
||
void CargarOnda( char *file, char far *Datos, char Ventana )
|
||
{
|
||
FILE *file_in;
|
||
int i;
|
||
char buffer[80];
|
||
|
||
struct CABECERA
|
||
{
|
||
long DPulsos[6];
|
||
} Cabecera;
|
||
|
||
if ( ( file_in = fopen( file, "rb" ) ) != NULL )
|
||
{
|
||
fread( &Cabecera, sizeof( CABECERA ), 1, file_in );
|
||
|
||
farfree( Datos );
|
||
if ( ( Datos = (char far *)farmalloc( sizeof(char)*Cabecera.DPulsos[5] ) ) == NULL )
|
||
{
|
||
sprintf( buffer, "longitud %ld bytes.", (long)(sizeof(char)*Cabecera.DPulsos[5]) );
|
||
Optar( 0, "ATENCION !!!", "No hay suficiente memoria", "no pude cargar el pulso", buffer, NULL );
|
||
for ( i = 0; i < 6; i++ )
|
||
Cabecera.DPulsos[i] = 0;
|
||
} else {
|
||
fseek( file_in, sizeof( CABECERA ), SEEK_SET );
|
||
fread( Datos, sizeof(char), Cabecera.DPulsos[5], file_in );
|
||
}
|
||
|
||
for ( i = 0; i < 6; i++ )
|
||
InicioPulso[i][Ventana] = Cabecera.DPulsos[i];
|
||
|
||
|
||
fclose(file_in);
|
||
}
|
||
|
||
}
|
||
|
||
|
||
void SalvarOnda( char *file, char far *Datos, char Ventana )
|
||
{
|
||
FILE *file_out;
|
||
int i;
|
||
|
||
struct CABECERA
|
||
{
|
||
long DPulsos[6];
|
||
} Cabecera;
|
||
|
||
if ( ( file_out = fopen( file, "wb" ) ) != NULL )
|
||
{
|
||
for ( i = 0; i < 6; i++ )
|
||
Cabecera.DPulsos[i] = InicioPulso[i][Ventana];
|
||
|
||
fwrite( &Cabecera, sizeof( CABECERA ), 1, file_out );
|
||
fseek( file_out, sizeof( CABECERA ), SEEK_SET );
|
||
fwrite( Datos, sizeof(char), Cabecera.DPulsos[5], file_out );
|
||
|
||
fclose(file_out);
|
||
}
|
||
|
||
}
|
||
|
||
|
||
|
||
void BorraPantalla(void)
|
||
{
|
||
int CLS;
|
||
setcolor( 0 );
|
||
randomize();
|
||
|
||
switch( random(4)+1 )
|
||
{
|
||
case 1:
|
||
for ( CLS = 0; CLS < 640; CLS+=2 )
|
||
{
|
||
line( CLS, 0, CLS, 479 );
|
||
line( 639-CLS, 0, 639-CLS, 479 );
|
||
delay( 10 );
|
||
}
|
||
break;
|
||
case 2:
|
||
for ( CLS = 0; CLS < 480; CLS+=2 )
|
||
{
|
||
line( 0, CLS, 639, CLS );
|
||
line( 0, 479-CLS, 639, 479-CLS );
|
||
delay( 10 );
|
||
}
|
||
break;
|
||
case 3:
|
||
for ( CLS = 0; CLS < 640*2; CLS+=2 )
|
||
{
|
||
line( 639-CLS, 0, 639 , CLS );
|
||
line( CLS, 479, 0, 480-CLS );
|
||
delay( 10 );
|
||
}
|
||
break;
|
||
case 4:
|
||
for ( CLS = 0; CLS < 640*2; CLS+=2 )
|
||
{
|
||
line( CLS, 0, 0, CLS );
|
||
line( 640-CLS, 479, 639, 480-CLS );
|
||
delay( 10 );
|
||
}
|
||
break;
|
||
}
|
||
|
||
|
||
}
|
||
|
||
void DibujaPulsos( long comienzo, char And_bit, char far *Datos, int x, int y, char color, long TotalPulsos )
|
||
{
|
||
long Pulso;
|
||
|
||
// seleccionamos el color de usuario
|
||
setcolor( color );
|
||
|
||
y += ALTO_PULSO + 5;
|
||
|
||
// moveto( x, y + ( comienzo > 0 ? ( ( Datos[comienzo-1] & And_bit ) ? ALTO_PULSO : 0 ) : 0 ) );
|
||
moveto( x, y - ( comienzo > 0 ? ( ( Datos[comienzo] & And_bit ) ? ALTO_PULSO : 0 ) : 0 ) );
|
||
for ( Pulso = comienzo; Pulso < ( comienzo + PULSO_QUE_CABEN ) & Pulso < TotalPulsos; Pulso++, x+=ANCHO_PULSO )
|
||
{
|
||
lineto( x, y - ( ( Datos[Pulso] & And_bit ) ? ALTO_PULSO : 0 ) );
|
||
lineto( x, y - ( ( Datos[Pulso+1] & And_bit ) ? ALTO_PULSO : 0 ) );
|
||
}
|
||
}
|
||
|
||
void DibujaSeparadores( int X1, int Y1, int X2, int Y2, char color )
|
||
{
|
||
setcolor( color );
|
||
|
||
setlinestyle( CENTER_LINE, 0, NORM_WIDTH );
|
||
|
||
for ( ; X1 < X2; X1 += ANCHO_PULSO )
|
||
line( X1, Y1, X1, Y2 );
|
||
|
||
setlinestyle( SOLID_LINE, 0, NORM_WIDTH );
|
||
|
||
}
|
||
|
||
|
||
void DibujaFondo(void)
|
||
{
|
||
FILE *fp;
|
||
int alto, ancho; unsigned char byte; int contador; char BitMap[40][40];
|
||
|
||
int x, y, vez = -1;
|
||
|
||
if ( ( fp = fopen ( "1.PCX", "rb" ) ) != NULL )
|
||
{
|
||
// Saltamos la cabecera
|
||
fseek( fp, 128, SEEK_SET );
|
||
|
||
for(alto=0; alto<32; alto++)
|
||
{
|
||
for(ancho=0; ancho<32; )
|
||
{
|
||
byte=getc(fp);
|
||
if(byte<=0xC0)
|
||
{
|
||
if ( vez == -1 ) vez = byte;
|
||
BitMap[ancho%32][alto%32] = byte;
|
||
ancho++;
|
||
}
|
||
else
|
||
{
|
||
contador=byte&0x3F; byte=getc(fp);
|
||
for(; contador>0; contador--)
|
||
{
|
||
BitMap[ancho%32][alto%32] = byte;
|
||
ancho++;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
// Rellenamos la pantalla con un fondo atractivo...
|
||
setfillstyle( SOLID_FILL, vez ); bar( 0, 0, 640, 480 );
|
||
for ( ancho = 0; ancho < 32; ancho++ )
|
||
for ( y = 0; y < 480; y+=35 )
|
||
for ( alto = 0; alto < 32; alto++ )
|
||
for ( x = 0; x < 640; x+=35 )
|
||
putpixel( x + ancho, y + alto, BitMap[ancho][alto] );
|
||
fclose( fp );
|
||
} else {
|
||
// Rellenamos la pantalla con un fondo atractivo...
|
||
setcolor( 1 );
|
||
setfillstyle( LTBKSLASH_FILL, 1 ); bar( 0, 0, 640, 480 );
|
||
}
|
||
|
||
|
||
|
||
Imprime_Estaticos( 10, "llave.img" );
|
||
|
||
|
||
/*
|
||
setfillstyle( SOLID_FILL, EGA_GREEN );
|
||
setcolor( 11 );
|
||
rectangle( 58, 23, 632, 197 );
|
||
*/
|
||
// & 58, 23, 632, 197, 0, 56, 63, 2, 2
|
||
// & 58, 273, 632, 447, 0, 56, 63, 2, 2
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
void AnulaInterrupcion(void)
|
||
{
|
||
/* reset the old interrupt handler */
|
||
if ( intvect == ON )
|
||
setvect(INTR, oldhandler);
|
||
intvect = OFF;
|
||
}
|
||
|
||
/***************************************************************************\
|
||
|* *|
|
||
|* INT CLK *|
|
||
|* *|
|
||
|* Descripci¢n: *|
|
||
|* interrupci¢n para el parpadeo de los led's *|
|
||
|* *|
|
||
|* Entradas: (indeterminadas) *|
|
||
|* *|
|
||
|* *|
|
||
|* *|
|
||
|* Salidas: (ninguna) *|
|
||
|* *|
|
||
\***************************************************************************/
|
||
void interrupt handler(__CPPARGS)
|
||
{
|
||
/* increase the global counter */
|
||
if ( IntVect == ON )
|
||
{
|
||
count = (count++)%16;
|
||
if ( count == 1 )
|
||
{
|
||
setpalette( 11, EGA_GREEN );
|
||
setpalette( 13, EGA_LIGHTGREEN );
|
||
}
|
||
else if ( count == 8 )
|
||
{
|
||
setpalette( 11, EGA_RED );
|
||
setpalette( 13, EGA_LIGHTRED );
|
||
|
||
}
|
||
}
|
||
|
||
/* call the old routine */
|
||
oldhandler();
|
||
}
|
||
|
||
|
||
void LeeFuentes(char *file)
|
||
{
|
||
FILE *fich;
|
||
/* Reservamos 4 Kb. para cargar la fuente en memoria */
|
||
|
||
/* Abrimos el fichero de la fuente */
|
||
|
||
if ((fich=fopen(file,"rb"))==NULL) {
|
||
printf("\a\nArchivo %s no encontrado.\n",file);
|
||
Error(0, "No se encuentra el archivo de fuentes");
|
||
}
|
||
|
||
fseek(fich, SEEK_SET, 0); /* Nos colocamos al principio del fichero */
|
||
fread(ptr_char,1,4096,fich); /* Cargamos en memoria 4096 bytes del fichero */
|
||
fclose(fich); /* Cerramos el fichero */
|
||
}
|
||
|
||
#define TAMx 8
|
||
#define TAMy 8
|
||
void Fuente_Amplia( char *Frase, p_Ampliada far *FA )
|
||
{
|
||
int i, j, k; // Variables de avance
|
||
int c_elec; // Color en el momento de imprimir
|
||
int PosX, PosY; // Posicion fisica final
|
||
char LCaract; // Caracter de linea a tratar
|
||
|
||
if ( FA->Flen != _fstrlen( Frase ) ) // Reseteamos las variables de control interno
|
||
{
|
||
// Obtenemos la longitud de la frase. ( En d¡gitos )
|
||
FA -> Flen = _fstrlen( Frase );
|
||
// Contador de digito actual a cero
|
||
FA -> BitByte = 0;
|
||
// Posicion dentro de la frase
|
||
FA -> currByte = 0;
|
||
}
|
||
|
||
// Avance horizontal de bit's ( avance de digitos )
|
||
for ( i = 0; i < ( TAMx * (FA -> ndigitos) ); i++ )
|
||
{
|
||
k = ( Frase[ ( (i+FA->BitByte)/TAMx + FA -> currByte ) % FA->Flen ] ) << 4;
|
||
LCaract = ( (char)0x01 << (7 - (i+FA->BitByte)%TAMx) );
|
||
PosX = FA -> x + FA->AX * i; // Posicion f¡sica horizontal
|
||
// Avance vertical de bit's
|
||
for ( j = 0; j < TAMy; j ++ )
|
||
{
|
||
PosY = FA -> y + FA->AY * j; // Posicion f¡sica vertical
|
||
|
||
if ( ptr_char[ k + j ] & LCaract )
|
||
c_elec = FA->C2;
|
||
else
|
||
c_elec = FA->C1;
|
||
|
||
putpixel ( PosX, PosY, c_elec );
|
||
}
|
||
}
|
||
// Tenemos en cuenta el avance dentro de la frase
|
||
if ( ( FA -> BitByte ++ ) >= 7 )
|
||
{
|
||
FA -> BitByte = 0; FA -> currByte ++;
|
||
if ( FA -> currByte >= FA -> Flen )
|
||
FA -> currByte = 0;
|
||
}
|
||
|
||
}
|
||
#undef TAMy
|
||
#undef TAMx
|
||
|
||
|
||
void Error( int code, char *MensajeError )
|
||
{
|
||
free( ptr_char );
|
||
AnulaInterrupcion();
|
||
restorecrtmode();
|
||
|
||
printf( "\nSe produjo un codigo de error %d, subcodigo no disponible ", code );
|
||
switch( code )
|
||
{
|
||
case 0:
|
||
printf( "\n Error Desconocido " );
|
||
break;
|
||
case 1:
|
||
printf( "\n BDatos gener¢ el error de salida. |ERROR DE ACCESO| " );
|
||
break;
|
||
case 2:
|
||
printf( "\n Make Boton gener¢ el error de salida " );
|
||
break;
|
||
case 3:
|
||
printf( "\n Fall¢ en alg£n punto del men£ principal" );
|
||
break;
|
||
|
||
};
|
||
|
||
printf( "\n> %s_", MensajeError );
|
||
exit(code);
|
||
}
|