From: "Johan Venter (aka sphinX)" <^_^@delorie.com> Newsgroups: comp.os.msdos.djgpp References: Subject: Re: beginner mode13 question Date: Tue, 22 Dec 1998 16:41:40 +1100 Lines: 39 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Newsreader: Microsoft Outlook Express 4.72.3110.5 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 NNTP-Posting-Host: 203.40.82.17 Message-ID: <367f57fa.0@139.134.5.33> X-Trace: 22 Dec 1998 18:27:38 +1000, 203.40.82.17 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com >unsigned char *VGA=(unsigned char *)0xA0000L; This is not going to work, because what you are specifying here is a near pointer in 32-bit memory without ever turning on nearptr addressing. To use near pointers in djgpp you need to call the __djgpp_nearptr_enable() function which is located in the sys/neaprtr.h include file. Be warned though, turning on nearptrs effectively turns off memory protection, but I think it is probably the easiest way to access graphics memory (particularly in mode 13h). So, to get your pointer use: #include unsigned char *vga; void set_up_graphics(void) { __djgpp_nearptr_enable(); vga = (unsigned char *)__djgpp_conventional_base + 0xA0000; } Then, in each of your functions, you will need to recalculate this address just in case __djgpp_conventional_base changes which may happen after memory allocs/deallocs. So, change your putpixel to the following: void plot_pixel(int x, int y, int colour) { VGA = (unsigned char *)__djgpp_conventional_base + 0xA0000; VGA[y*320+x]=colour; } When your program exits, don't forget to turn off nearptrs with __djgpp_nearptr_disable(); -- sphinX e-mail: sphinx_ AT iname DOT com icq: 3643877