From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: 0xA0000000h Date: Sat, 25 Jan 1997 22:49:07 -0800 Organization: Two pounds of chaos and a pinch of salt Lines: 55 Message-ID: <32EAFE63.2E81@cs.com> References: <01bc0a29$44be7280$b27a388f AT JNTF DOT jntf DOT osd DOT mil> <5cdtoq$li6$1 AT news DOT sas DOT ab DOT ca> Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: ppp105.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit CC: Russ Hubbard To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp jonklipp AT freenet DOT edmonton DOT ab DOT ca wrote: > > : How would I create an array for video memory in djgpp? > : Currently I have: > > : char far *video_buffer = (char far)0xA0000000L; > > char *video_buffer = (char *)0xA0000; // 0xA0000, because it uses 32-bit > protected mode addresses (or something, I'm not quite sure :)) Close. This must read something like the following: if ( __djgpp_nearptr_enable() ) { char *video_buffer = (char *)(__djgpp_conventional_base + 0xA0000); video_buffer[y*320+x] = color; __djgpp_nearptr_disable(); } You must always add __djgpp_conventional_base to the absolute memory address, because all addresses are computed relative to your program's address space! Note also that there are some library functions that can change the program's base address. For maximum safety, you should recalculate __djgpp_conventional_base + 0xA0000 every time you call a given function. Also, the nearptr_enable and nearptr_disable functions are relatively heavy cycle-eaters. If you are _certain_ that your program doesn't have any rogue pointers that might damage sensitive areas of memory, you can try disabling them at the beginning of your program and enabling them at the end. Otherwise, it's probably best to leave near pointers off until you enter those portions of your program that need them. The FAQ discusses this subject quite extensively in chapters 10, 17, and 18, and also points you to several very handy references on the net. For a way to do this sort of thing without needing to worry about all the memory protection hacks, check out the allegro graphics library. It's a fantastic library that runs nearly as fast as the best optimized code, and it handles all the memory issues for you! The latest version is available from and several other locations. l8r -- --------------------------------------------------------------------- | John M. Aldrich, aka Fighteer I | fighteer AT cs DOT com | | Call me for your free AOL disk! | http://www.cs.com/fighteer | | Chain letters, work-at-home schemes, free long distance, etc., | | are ILLEGAL! Keep the Internet litter-free... don't SPAM. | ---------------------------------------------------------------------