Message-ID: <33AC09E8.911@oregoncoast.com> Date: Sat, 21 Jun 1997 10:05:44 -0700 From: Rudy Gingles Organization: Atek Systems MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: Access video memory. References: <339FA5AB DOT 418243FC AT sr DOT flashnet DOT it> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 40 NNTP-Posting-Host: news.oregoncoast.com To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Seby wrote: > > How I can access video memory from mouse interrupt handler ? > With nearptr i have no errors, but no drawings too!!!!! > Using farptr generate a "general protection" or "page fault" errors.... > DAMNED DJGPP !!! :o) > Help me please...... > > Seby Carta. This is what I did, and it works perfectly: unsigned char *screen; if (!__djgpp_nearptr_enable()) { printf("Error enabling nearptr!\n"); exit(-1); } screen = (char *)(__djgpp_conventional_base + 0xa0000); Now you can access the video memory simply by writing to screen[]. When you are all done: __djgpp_nearptr_disable(); Thats all there is to it! A couple things to be aware of in your code: 1. Never ASSUME __djgpp_nearptr_enable() will work. It can fail. 2. Notice that I'm specifying the video memory address as 0xa0000, and not just 0xa000. This is because the address is a physical memory address, not a segment, or selector. 3. Also notice that you must add __djgpp_conventional_base to the address. You must re-do this EVERY time you do a __djgpp_nearptr_enable(), since you can't guarantee that __djgpp_conventional_base will return the same value each time. Don't pre-record it. Hope that helps, Rudy Gingles