www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/31/17:44:09

From: "Sean L. Palmer" <seanpalmer AT mindspring DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: allegro - sprites and smudge on screen
Date: 31 Mar 1997 19:24:55 GMT
Organization: MindSpring Enterprises
Lines: 39
Message-ID: <01bc3e07$bd7fe520$cf0b1d26@ghost.artnet.net>
References: <199703181247 DOT NAA10767 AT gilberto DOT physik DOT rwth-aachen DOT de> <qR$ZTcAmxvLzEw5v AT talula DOT demon DOT co DOT uk>
Reply-To: "Sean L. Palmer" <spalmer AT pobox DOT com>
NNTP-Posting-Host: ip207.van-nuys2.ca.pub-ip.psi.net
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

> >While I'm moving a round the sprite smudge gets spattered over
> >the screen (pieces of the sprite, pixels are set where they not
> >should be etc etc.).
> >
> >When I'm doing a show_mouse(NULL) before I'm doing the drawing the
> >smudge disappears but this is leading to intolerable flickering
> >of the sprite.
> 
> Drawing to the screen while the mouse pointer is being displayed is a
> bad thing for two reasons:
> 
> - In order to restore what was under the mouse when it next moves, 
>   Allegro stores a copy of what lies underneath it on the screen. If you 
>   draw something else over the top of the cursor, this buffer will 
>   become invalid. If you then move the mouse, the old, incorrect image 
>   will get restored where it used to be, so it will leave some 'mouse 
>   droppings' behind...
> 
> - The mouse pointer is drawn inside a timer interrupt, which means that 
>   it may get drawn while the main program is in the middle of some other 
>   drawing operation. This wreaks havoc with the SVGA bank switching 
>   mechanism, as the mouse drawing code will change bank, and then return 
>   from the interrupt to the other drawing function which fails to 
>   realise that it now needs to switch back to whatever bank it was 
>   previously using. This can result in pixels being written to 
>   completely the wrong part of the screen, but is only a problem in 
>   banked SVGA modes.

The best solution is to (in the mouse interrupt) set a flag that the mouse
has moved, and store where to or how much.  Then later after you've done
the main drawing stuff, move the mouse if needed.

If you let Allegro handle saving/restoring the mouse, it will definitely
flicker.  The best kind of sprites are the ones that either (A) don't get
restored, ever, or (B) always get saved/restored in a certain order (LIFO).

You can always check the SVGA for what bank it's currently in in the timer
interrupt if you insist on doing it that way, and restore it on exit.

- Raw text -


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