You are here:

C/clrscr() function SVGA !

Advertisement


Question
QUESTION: 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.

Answer
Dear 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  

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


Prince M. Premnath

Expertise


I'm sure that I can solve any doubts in Turbo C ,Graphics Programing ,Mouse, Hardware Programming ,File System ,Interrupts, BIOS handling , TSR Programming , General Concepts in C Language, handling inline Assembly statements

Experience

Research over 6+ Years

Organizations
CG-VAK Softwares and Exports Limited

Education/Credentials
Masters in Computer Applications

©2012 About.com, a part of The New York Times Company. All rights reserved.