From: Ryan Blazecka Newsgroups: comp.os.msdos.djgpp Subject: Re: Allegro mouse question. Date: Mon, 03 Feb 1997 22:55:51 -0800 Organization: BCTEL Advanced Communications Lines: 49 Message-ID: <32F6DD77.2D4F@bc.sympatico.ca> References: Reply-To: eblazecka AT bc DOT sympatico DOT ca NNTP-Posting-Host: nwmr01m03-74.bctel.ca 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 Andrew Deren wrote: > > I am planning to writea game that requires a mouse for pointing > things, and I am having problems with that because in allegro (that's what > i use and like) you have to hide and show mouse whenever you write to > screen and I am updating the screen at about 20-30 fps and this causes the > mouse to disapear and show. Is there some way to blit something to a sreen > without hidding mouse pointer? > Thanks in advance. > Unfortunately, you cannot have the mouse interrupt handler drawing the mouse cursor on the screen at the same time as you are drawing your graphics (unless this is mode13h, and you constrain mouse motion away from wherever you're drawing, but that's rarely useful, and another story altogether). So you have to turn the mouse off whenever you draw to video memory, then turn it back on when you're done. But whoever said you have to turn it back on? If you are redrawing the entire screen every frame, you can just leave Allegro's mouse pointer off, and before you blit your off-screen buffer to the video display, draw your mouse pointer to the buffer using mouse_x and mouse_y (since they are still updated, even though the cursor isn't visible.) This technique can also be applied to a system that uses hardware page flipping. Still leaving Allegro's mouse cursor off, you need to maintain two bitmaps, which are the images of what is behind the mouse cursor on the two separate pages. Before you do a page flip, you save the background behind the mouse cursor on the hidden page, then draw the mouse cursor over the place you just saved. Then do the page flip. The previously visible page is now hidden, so erase the mouse cursor on that page by blitting the previously saved background for that page over the old mouse cursor, and update the rest of that frame. Do the page flip again (saving the background and blitting the cursor first, of course), and update the other page. If 20-30 fps is too slow for smooth mouse motion, you'll have to go into the Allegro source, make a few variables, and change a few functions. You'll need a mouse_frozen variable, which you set to TRUE when you want to draw, and FALSE when you're done. Then, in the interrupt handler, before drawing the mouse cursor, check if mouse_frozen is equal to TRUE. If it is, just return without drawing anything. The mouse cursor will still be visible, eliminating flicker, it just won't change. This works better with the hardware page flipping method. Hope that this makes sense, Ryan Blazecka eblazecka AT bc DOT sympatico DOT ca