delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/14/12:34:49

From: lonniem AT cs DOT utexas DOT edu (Lonnie McCullough)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Clearing the screen in VESA VBE 2.0
Date: Mon, 14 Jul 1997 00:56:24 GMT
Message-ID: <33c97858.1689804@news.nol.net>
References: <33c91f25 DOT 2277017 AT news DOT praxis DOT net>
NNTP-Posting-Host: ip38-18.nol.net
Lines: 43
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Sun, 13 Jul 1997 18:36:25 GMT, bradh AT praxis DOT net (Brad House) wrote:

>And to try to clear the screen, I try to set VideoSelector to Black to
>clear the screen such as:
>memset((void *)VideoSelector, 0, SCREEN_W*SCREEN_H);
>but my computer totally fucks up......can you tell me why this
>happens....or another way to clear the screen.......thanx!

Well I didn't look at the rest of your code but the most obvious
reason that it messes up is because you are probably writing over some
important code or data.  memset (and all standard C/C++ functions)
take pointers that are relative to your program's ds.  When you try to
pass VideoSelector as a pointer (which is not what it is really) you
are telling memset to set portions of the memory occupied by your data
segment with an offset of VideoSelector (whatever value that may have)
relative to your ds to 0 which is never good.  What you really want to
do is load the descriptor into a selector (ds is a good choice so long
as you save and restore it _VERY_IMPORTANT_) then use one of the rep
movs family of instructions.  Also you could do this:

#include <sys/farptr.h>

void clear (long color)
{
  long i;

  color = color | color << 8;  /* only for 8bpp */
  color = color | color << 16;

  _farsetsel (VideoSelector);

  for (i = 0; i < (SCREEN_W * SCREEN_H); i+= 4)
    _farnspokel (i, color);
}

Not as fast as the rep movs stuff but it will work assuming all the
other code was correct (i.e. you correctly allocated a descriptor and
all that junk you need to do to make things jive peacfully).



Lonnie McCullough
lonniem AT cs DOT utexas DOT edu

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019