delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/06/23/22:16:59

From: "Mark Oliver" <markoliv AT mercury DOT kosone DOT com>
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

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 <spy AT oregoncoast DOT com> 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
> 

- Raw text -


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