delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/25/13:05:40

Date: Fri, 25 Jul 1997 10:04:56 -0700 (PDT)
Message-Id: <199707251704.KAA26954@adit.ap.net>
Mime-Version: 1.0
To: bminier AT aol DOT com
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: Direct video access.
Cc: djgpp AT delorie DOT com

You wrote:
>Hello, I am trying to write directly to the video without using bios or
>dos.  But 
>everytime I try this following program, I get a SIGSEGV (which i am
>guessing means a segment violation?)  I attempted to re declare vidptr as
>char far *vidptr but DJ does not recognize it.  So, what am I doing wrong?
>
>int
>main (void)
>{
>  char *vidptr = (char *) 0xB8000000;
>
>  *vidptr = 'a';                      /* Write a to screen. */
>  *(vidptr + 1) = (char) 1;      /* In blue. */
>
>  return 0;
>}
DJGPP runs programs in protected mode. You can't access outside your
program's space with normal pointers. This is a feature.
The way to do what you want is probably like this:

int main(void)
{
   short vid_sel;
   vid_sel = __dpmi_segment_to_descriptor(0xB800); /* Make the selector */
   if (vid_sel == -1) abort(); /* or bomb out some other way */
   farpokeb(vid_sel,0,'a');
   farpokeb(vid_sel,1, 1 );
   return 0;
}

Nate Eldredge
eldredge AT ap DOT net



- Raw text -


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