From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: Polling busy video memory Date: Sat, 07 Feb 1998 14:31:14 -0500 Organization: Two pounds of chaos and a pinch of salt. Lines: 47 Message-ID: <34DCB682.1D3F@cs.com> References: <6bibs8$l0i$1 AT herald DOT Mines DOT EDU> NNTP-Posting-Host: ppp209.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Jean-Luc Romano wrote: > > Does there a function in DJGPP or Allegro that returns whether > the video memory is busy or not? > > Something along the lines of: > > if ( is_video_memory_busy() ) > printf("Still writing to video memory.\n"); > else > printf("Video memory is available for use.\n"); > > > I figure something like this would be useful in writing the > screen buffer to the screen only when the screen is available, so > the program doesn't have to halt until it can blit the video buffer > again (if that made any sense). AFAIK, unless you are talking about a multithreaded system wherein one thread handles writing to video memory and another handles generating the graphics, then your question is meaningless. The basic task of blitting is a loop that copies data from your program into the video memory; it is part of your program like any other. If you are discussing some sort of interrupt code, such as a timer or mouse handler, which might be called at any time during your program, then you must remember that interrupt handling code should be as small and as fast as possible, to avoid disrupting the system for any length of time. Only very rarely should interrupt code draw anything to the screen. For example, if you are writing a mouse handler, the easiest thing to do is have the handler update a counter in your program that represents the mouse position, and have your graphics code read the counter and draw the mouse pointer along with the rest of the screen. With the above points in mind, it's trivial to create a global variable in your code that holds a flag set by the blitting code when it starts, and reset when it finishes. There's no need, nor is there any convenient way to detect such a situation in hardware. To the CPU, one memory address is like any other. -- --------------------------------------------------------------------- | John M. Aldrich | "Always listen to experts. They'll | | aka Fighteer I | tell you what can't be done, and why.| | mailto:fighteer AT cs DOT com | Then do it." | | http://www.cs.com/fighteer/| - Lazarus Long | ---------------------------------------------------------------------