From: Shawn Hargreaves <Shawn AT talula DOT demon DOT co DOT uk> Newsgroups: comp.os.msdos.djgpp Subject: Re: Allegro and the mouse Date: Sat, 8 Feb 1997 16:12:37 +0000 Organization: None Distribution: world Message-ID: <KE$BWEA1XK$yEwIo@talula.demon.co.uk> References: <5die25$13s_001 AT gn6 DOT noord DOT bART DOT nl> NNTP-Posting-Host: talula.demon.co.uk MIME-Version: 1.0 Lines: 29 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Douglas Eleveld writes: >When I draw onto a winddow, I first check if the mouse is in the window >and if it is not, then I just draw, and if it is in the window, I erase the >mouse before drawing in the window. That means that sometimes I'll be >drawing on the screen with a visible mouse pointer, but not over the >drawing region. Is this dangerous? I haven't had any problems so far. It depends on the video mode. In mode 13h or linear framebuffer SVGA modes it is quite safe, but in banked SVGA modes you could run into difficulties. The problem is that the mouse pointer is drawn in a timer interrupt, which could preempt your drawing code. Say you call rectfill() to draw something at the bottom of the screen. This selects the appropriate bank for writing to the bottom of video memory, but what if the user moves the mouse in the middle of the rectfill() operation? The mouse drawing code will switch banks to draw the pointer up at the top of the screen, so when it returns from the interrupt and resumes the rectfill, the wrong bank will be selected. The worst that can result is garbage on the screen, though: there's no way it can crash your program. A possible fix would be to make the mouse code save and restore the current bank, but this is buggy under several VESA drivers that I've tried. Another option would be to disable interrupts while you do the drawing, but that isn't a good idea unless you are going to finish and reenable them _really_ quickly... /* * Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/ * Ghoti: 'gh' as in 'enough', 'o' as in 'women', and 'ti' as in 'nation'. */