COMPACTA/KEY.CPP
2021-09-03 17:51:51 +02:00

32 lines
712 B
C++

#include <alloc.h>
#include <conio.h>
#include <dos.h>
#include <mem.h>
void *Pantalla;
int x,y;
void main(void)
{
int key = 0, key1 = 1;
if ( ( Pantalla = malloc( 4096 ) ) == NULL ) return;
// Guardamos el contenido de la pantalla
memcpy( Pantalla, MK_FP(0xB800,0), 4096 );
x = wherex(); y = wherey();
clrscr();
cprintf( "Para Salir pulse ESC ( sc.27 )\n\r" );
cprintf( "------------------------------\n\r" );
while( key != 27 )
{
if ( ( key = getch() ) ==0 ) key1 = getch(); else key1 = 0;
cprintf( " % 3d % 3d \n\r", key, key1 );
}
// Restauramos el contenido
memcpy( MK_FP(0xB800,0), Pantalla, 4096 );
gotoxy( x, y );
free( Pantalla );
}