Mail Archives: djgpp/1997/06/25/13:33:45

Message-ID: <>
Date: Sat, 21 Jun 1997 10:05:44 -0700
From: Rudy Gingles <spy AT oregoncoast DOT com>
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>
Lines: 40
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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");
   screen = (char *)(__djgpp_conventional_base + 0xa0000);

Now you can access the video memory simply by writing to screen[]. When you 
are all done:


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 -

  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019