#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 68 #define CLOCK_Y 3 void interrupt Clock( void ); void PutChar( unsigned char ); void MoveCur( unsigned char, unsigned char ); void DisplayByte( unsigned char ); void (interrupt far *p) (void); void main() { clrscr(); disable(); p = getvect( INT_NO ); setvect( INT_NO, Clock ); enable(); printf( "Reloj TSR 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 is = 0, f = 1; struct text_info *r; struct time *st; p(); is++; if( is == 18 ) { is = 0; st = (struct time*) malloc( sizeof( struct time ) ); r = (struct text_info*) malloc( sizeof( struct text_info ) ); gettime( st ); gettextinfo( r ); MoveCur( CLOCK_X, CLOCK_Y ); DisplayByte( st->ti_hour ); if( f ) { PutChar( ':' ); f = 0; } else { PutChar( ' ' ); f = 1; } DisplayByte( st->ti_min ); MoveCur( r->curx + r->winleft - 2, r->cury + r->wintop - 2 ); free( r ); free( st ); } }