#include #include #include #include #include #include #define PRINT_SCREEN 0x05 #define VIDEO 0x10 #define BREAK 0x1B #define TIMER_TICK 0x1C #define TIME_OF_DAY 0x08 /*IRQ 0*/ #define KEYBOARD 0x09 /*IRQ 1*/ #define COM2 0x0B /*IRQ 3*/ #define COM1 0x0C /*IRQ 4*/ #define LPT2 0x0D /*IRQ 5*/ #define FLOPPY 0x0E /*IRQ 6*/ #define LPT1 0x0F /*IRQ 7*/ #define REAL_TIME 0x70 /*IRQ 8*/ #define IRQ11 0x72 /*IRQ 10*/ #define IRQ12 0x73 /*IRQ 11*/ #define IRQ13 0x74 /*IRQ 12*/ #define COPROCESSOR 0x75 /*IRQ 13*/ #define HARD_DISK 0x76 /*IRQ 14*/ #define IRQ15 0x77 /*IRQ 15*/ #define INT_NO TIMER_TICK #define CLOCK_X 70 #define CLOCK_Y 2 void interrupt Clock( void ); void PutChar( unsigned char ); void MoveCur( unsigned char, unsigned char ); void (interrupt far *p) (void); void main() { clrscr(); disable(); p = getvect( INT_NO ); setvect( INT_NO, Clock ); enable(); printf( "Reloj TSR propietario inicializado\n" ); keep( 0, 1000 ); /* while( getche() != 'a' ); disable(); setvect( INT_NO, p ); enable(); */ } void PutChar( unsigned char c ) { union REGS *inreg, *outreg; inreg = malloc( sizeof( union REGS ) ); outreg = malloc( sizeof( union REGS ) ); inreg->h.ah = 0x0e; inreg->h.al = c; inreg->h.bh = 0x0; inreg->x.cx = 0x1; int86( 0x10, inreg, outreg ); free( outreg ); free( inreg ); } void MoveCur( unsigned char x, unsigned char y ) { union REGS *inreg, *outreg; inreg = malloc( sizeof( union REGS ) ); outreg = malloc( sizeof( union REGS ) ); inreg->h.ah = 0x02; inreg->h.dh = y; inreg->h.dl = x; inreg->h.bh = 0x0; int86( 0x10, inreg, outreg ); free( outreg ); free( inreg ); } void DisplayByte( unsigned char c ) { int a; a = c / 10; PutChar( '0' + a ); a = c - a * 10; PutChar( '0' + a ); } void interrupt Clock( void ) { static int h = 0, m = 0, s = 0, is = 0, im = 0, f = 1; struct text_info *r; unsigned char x, y; p(); if( f ) { struct time *st; st = malloc( sizeof( struct time ) ); gettime( st ); m = st->ti_min; h = st->ti_hour; free( st ); r = (struct text_info*) malloc( sizeof( struct text_info ) ); gettextinfo( r ); x = r->curx + r->winleft - 2; y = r->cury + r->wintop - 2; free( r ); MoveCur( CLOCK_X, CLOCK_Y ); DisplayByte( h ); PutChar( ':' ); DisplayByte( m ); MoveCur( x, y ); f = 0; } is++; if ( is == 18 ) { r = (struct text_info*) malloc( sizeof( struct text_info ) ); gettextinfo( r ); x = r->curx + r->winleft - 2; y = r->cury + r->wintop - 2; free( r ); MoveCur( CLOCK_X+2, CLOCK_Y ); if( s ) { PutChar( ':' ); s = 0; } else { PutChar( ' ' ); s = 1; } is = 0; MoveCur( x, y ); } im++; if ( im == 1092 ) { r = (struct text_info*) malloc( sizeof( struct text_info ) ); gettextinfo( r ); x = r->curx + r->winleft - 2; y = r->cury + r->wintop - 2; free( r ); MoveCur( CLOCK_X+3, CLOCK_Y ); DisplayByte( m ); if( !m ) { MoveCur( CLOCK_X, CLOCK_Y ); DisplayByte( h ); } m++; im = 0; MoveCur( x, y ); } if( m == 60 ) { m = 0; h++; } if( h == 24 ) h = 0; }