From: "Mark Oliver" Subject: Re: Access video memory. Newsgroups: comp.os.msdos.djgpp References: <339FA5AB DOT 418243FC AT sr DOT flashnet DOT it> <33AC09E8 DOT 911 AT oregoncoast DOT com> Message-ID: <01bc7f5d$1c4fa900$aa28bace@client.kosone.com> Date: 22 Jun 97 22:35:27 GMT Lines: 51 NNTP-Posting-Host: apollo.kosone.com Organization: Kingston Online Services To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk to add to this, if you are doing graphic, it is a good idea to do this every frame (it isn't expensive) screen = (char *)(_djgpp_conventional_base + 0xa0000); just a thought Rudy Gingles wrote in article <33AC09E8 DOT 911 AT oregoncoast DOT com>... > 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 >