C/C clrscr(()
Expert: Prince M. Premnath - 11/7/2006
QuestionI wants to know how clrscr() works in graphics window. Please give me the coding for clrscr() that can work in turbo c.
AnswerDear Babu !
1.clrscr() Function in turbo C is completly dedicated for text mode , any how if you used with graphics mode it will partially erase the screen with white color ! ( This is actually a mal function ) inorder to erase the screen completly in graphics mode use cleardevice() function.
2. Clrscr() is actually a ROM-BIOS based function , used to scroll the window UP !
1. suppose assume that you are working in 80x25 mode screen ( 80 cols and 25 lines ) .
2. If you scroll up for 25 lines then the full screen will be cleared.
3. The BIOS function takes the form .
interrupt 0x10
AH = 0x06 // 0x07 for scroll down.
AL = # of Lines to scroll .
BH = 0 // Fill with BLACK
CH = 1 // Upper Row
Cl = 1 // Upper Column
DH = Lower Row
DL = Lower column
NOte :
This is the function what i have written using TurboC and Turbo Assembler (TASM).
void scrollup(char noLines , char x1 , char y1 , char x2 , char y2)
{
asm mov ah , 0x06;
asm mov al , noLines;
asm mov cl , x1;
asm mov ch , y1;
asm mov dl , x2;
asm mov dh , y2;
asm mov bh , 0;
asm int 0x10;
}
void clrscr()
{
scrollup(0 , 0 , 0 , 79 , 24);
}
This code will be difficult to use ,
better use the following code it will work on turbo C.
and you have to include the header - #include<dos.h>
void scrollup(int noLines , int x1 , int y1 , int x2 , int y2)
{
union REGS reg;
reg.h.ah= 0x06;
reg.h.al= noLines;
reg.h.cl = x1;
reg.h.ch = y1;
reg.h.dl = x2;
reg.h.dh = y2;
reg.h.bh = 0;
int86(0x10 , ® , ®);//correct here if it appears wrong
}
void clrscr()
{
scrollup(0 , 0 , 0 , 79 , 24);
}
note : There is the problem given in our editor , it dont accepting the & reg symbol therefore use ® ,® in 2nd and 3rd arguement of int86 function.
Regards !
Prince M. Premnath.