Date: Mon, 2 Oct 1995 08:19:14 +0200 (IST) From: Eli Zaretskii To: Jonathan Nix Cc: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: Re: Help: Direct video/inline asm On 30 Sep 1995, Jonathan Nix wrote: > This is rather premature, sorry. I'm sure theres a way, but when I; > > char *vidmem=(char *)0xA0000000L; > > And then try to plot a pixel or somthing; > > vidmem[y<<8+y<<6+x]=color; > > DJGPP returns a general protection fault. Sure, it does. The reason why and the right way to do it are explained in the DJGPP FAQ list (available as faq102.zip from the same place you get DJGPP), in section 10.6: 10.6 Q: I try to access the video memory at 0xa0000, but get Segmentation violation... A: Absolute addresses of certain memory-mapped devices are mapped differently under DJGPP, which is protected-mode environment. You can't just poke any address, that's what protected mode is all about. In non-DPMI mode, the entire graphics video memory is mapped 1:1 starting at 0xD0000000 in the program's address space; the DJGPP paging mechanism understands how SuperVGA's map their memory onto the AT bus and automatically swaps pages as the program tries to access them. The program sees a linear range from 0xD0000000 to 0xD0100000 that corresponds to each pixel in the 256-color modes of SuperVGAs. For this to work correctly, you will have to set the GO32 environment variable to the graphics driver suitable for your SuperVGA card, like this: SET GO32=driver c:\djgpp\drivers\ati.grd gw 640 gh 480 tw 132 th 43 In DPMI mode this won't work. As DJGPP v2.0 will be DPMI-only environment, this means that, after GRX 2.0 arrives, the above method should be used only as last resort. If you want to write a program which will compile and run unchanged in v2.0, use functions described in (see chapter 18 below for details).