here is the complete code
Code:
#include <dos.h>
#include <conio.h>
void interrupt (*oldTimer)(void);
void interrupt (*oldKey)(void);
void interrupt newTimer ( );
void interrupt newKey ( );
void clearScreen(void);
void printInfo(int);
char far *scr = (char far* ) 0xB8000000; //Address of video memory.
char far *kbd = (char far* ) 0x00400017; //Keyboard status byte.
int i, t = 0, m = 0;
char charscr [4000];
void main( )
{
oldTimer = getvect(8); //Save the old timer routine in oldTimer (interrupt function pointer)
oldKey = getvect (9); //Save the old keyboard routine in oldKey (interrupt function pointer)
setvect (8,newTimer); //Replace the functionality of orginal routine with new one.
setvect (9,newKey);
keep(0,1000); //Making this program TSR
getch();
getch();
}
//This function will be invoked after every 1/18.2 th of second.
void interrupt newTimer ( )
{
t++;
if((t >= 91) && (m == 0))
{
for (i =0; i < 4000; i ++)
{
charscr [i] = *(scr + i); //Save the original screen into charscr[] array
}
m=1;
}
if (t >= 91 && m == 1) //Check if 5 seconds have passed.
{
clearScreen();
printInfo(1990);
}
(*oldTimer) ( );
}
void clearScreen()
{
int i;
// Write the spaces with withe back color in whole screen
for (i =0; i <=4000; i +=2)
{
*(scr + i) = 0x20; //ASCII code of space key
*(scr + i + 1) = 0x70; //Means white fore colr and black back color
}
}
void printInfo(int i)
{
*(scr + i) = 0x41;
*(scr + i + 1) = 0x70;
i+=2;
*(scr + i) = 0x42;
*(scr + i + 1) = 0x70;
i+=2;
*(scr + i) = 0x43;
*(scr + i + 1) = 0x70;
i+=2;
*(scr + i) = 0x28;
*(scr + i + 1) = 0x70;
i+=2;
*(scr + i) = 0x42; // ASCII code of 'B'
*(scr + i + 1) = 0x70; // Means Black fore colr and White back color
i+=2;
*(scr + i) = 0x43; // ASCII code of 'C'
*(scr + i + 1) = 0x70;
i+=2;
*(scr + i) = 0x30; // ASCII code of '0'
*(scr + i + 1) = 0x70;
i+=2;
*(scr + i) = 0x30;
*(scr + i + 1) = 0x70;
i+=2;
*(scr + i) = 0x30;
*(scr + i + 1) = 0x70;
i+=2;
*(scr + i) = 0x30;
*(scr + i + 1) = 0x70;
i+=2;
*(scr + i) = 0x30;
*(scr + i + 1) = 0x70;
i+=2;
*(scr + i) = 0x30;
*(scr + i + 1) = 0x70;
i+=2;
*(scr + i) = 0x30;
*(scr + i + 1) = 0x70;
i+=2;
*(scr + i) = 0x30;
*(scr + i + 1) = 0x70;
i+=2;
*(scr + i) = 0x30;
*(scr + i + 1) = 0x70;
}
void interrupt newKey ( )
{
int w;
if (inportb(0x60)==0x10 && m==1 && ( ((*kbd)&12)==12 ))
{
for (w =0; w < 4000; w ++)
{
//Restoring the original screen
*(scr + w) = charscr [w]; // Whenever Alt+Ctrl+Q is pressed original screen will be restored
}
m = 0;
t = 0;
}
(*oldKey) ( );
}