C/clrscr() function SVGA !
Expert: Prince M. Premnath - 6/12/2007
QuestionQUESTION: how to clear the screen in svga mode.In a previously asked question you said that only possibility is to "just repaint the screen with BLACK color its enough for that ( This is a standard procedure )".Can you tell that standard procedure.
ANSWER: Dear Mr Rizwan!
Ya of course its a good option ! Let me explain u what will happen if you repaint the screen Using BLACK ,
Upon setting black color ( code 0 ) it will set all the bytes in video memory to 0 ( Thats the standard procedure to erase the screen )!
Thanks and Regards!
Prince M. Premnath
---------- FOLLOW-UP ----------
QUESTION: can u tell me with the help of a sample code.
AnswerDear Mr Rizwan !
There are many approach to clear the screen under SVGA mode !
1.Bank switching.
Hope bank switching will help you in this case , but switching operation is not a recommended one , thats because performance matters !
2. For a better performance you can use the following code , this will re paint the whole window using the black color , since this program write the value directly to the video memory this will eork much faster !
void bar(int x , int y , int width , int height , int color)
{
long offset = (long) (y) * xmax + (long) (x) ;
char offset2 = offset >> 16;
int i , j;
long temp;
if(offset2 != bank) setbank(offset2);
offset = offset % max;
for( i = 0 ; i < height ; i++)
{
for( j = 0; j < width ; j++)
{
temp = 0xA0000000L + offset;
*((char far*) temp) = color;
if(offset >= max-1){
offset2++;
setbank(offset2);
offset = 0;
}
else
offset = offset + 1;
}
offset = offset + xmax - width;
if( offset >= max - 1)
{
offset2++;
setbank(offset2);
offset = offset % max;
}
}
}
void cleardevice()
{
bar(0 , 0 , getmaxx() , getmaxy() , 0);
}
For further reference please refer this material !
http://www.vesa.org/public/VBE/vbe3.pdf
Thanks and Regards !
Prince M. Premnath