Mail Archives: djgpp/1997/06/25/13:33:45
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
- Raw text -