From: Emil0 AT aol DOT com Date: Wed, 23 Oct 1996 18:09:05 -0400 Message-ID: <961023180905_339586309@emout17.mail.aol.com> To: leathm AT gbrmpa DOT gov DOT au cc: djgpp AT delorie DOT com Subject: Re: Another way to access VGA memory Leathal wrote: >Hey dudes... > >I started using selectors (such as %fs) but gave up after about 2 days. >Why? >Every time I want to write to a section of the graphics screen, I call >a routine - say blit. Everytime blit is called, I have to reload the >selector. Every time I exit the blit routine, I have to restore the >selector. > >Using near pointers, you never have to worry about that. And I have >never >written a program where the __djgpp_conventional_base changes... could >someone explain to me a situation where it does? I have never >encountered >this when only running my application (I do just about everything under >Win95 too... :) > >Just have a variable gfx_screen which points to the physical memory area >of the graphics screen, add the __djgpp_conventional_base to it, and >then >always just use that variable. Easy, no? > >Leathal. Leathal, I started this thread, but I only read the weekly digest, so I've only just seen your reply. Using near pointers in no quicker because you still have to load the %edi register with your pointer and then no doubt add some stuff to this to access the right pixel. With my method you load %es or whatever and then load stuff into %edi to point to the right pixel - so it is not slower (apart from perhaps another register to save on the stack, although a push and a pop will hardly slow a program down even if done hundreds of times a second). With my method you retain full memory protection and it will work under all DPMI providers. It is a safe method which is guaranteed to work in the future and with DOS emulators on other machines. The near pointer method is really a hack, so for professional stuff I'd recommend my method which is far neater. For example, say you're testing a bit blitter, a gp fault is caused when you write outside video memory. Another thing, __djgpp_conventional_base is not guaranteed to stay the same - currently it does, but in future this may change. I think that the protection offered by my method far out-weighs the hassle of having to save and restore a single register. My method is for people who want to write bullet-proof code which runs fast. Richard. :) ps. Web page authors! Put this method on your sites please!