Greg_d._Moore@mts.rpi.edu (Commander Krugannal) (03/25/90)
Several people have asked about direct video access and
several others have responded. I want to add to this though.
If you want to access Hercules or Monochrome Adapter,
the base offset it B0000.
CGA/EGA/VGA are B8000. (Note that actually EGA/VGA are
located at A0000 but the card does funky thing to keep you
from normally accessing this area. Unless you are real sucidal
or doing graphics stuff and REALLY know what you are doing,
don't try it... :-)
Code has already been given for accessing the first byte.
But, keep in mind that each character on the screen takes two
bytes in memory, the first is the character itself, and the
second is the color (or attribute). So, you have to read as
twice as many bytes as characters as you want. (or read every
other one. It depends on the application. If you want to read
a portion of the window so that you can save it and restore it,
read every one so that you restore the correct color.)
Someone mentioned that old CGA monitors produce "snow" when
you directly access video memory. This is true (though I haven't
found any new ones that don't either...). This can be taken care
of in a simple manner. By checking when the screen retrace is
done, you then disable it and all interrupts, do the memory
i/o then renable it and all interrupts. I don't have the code
with me to show you how to do it, but it is farily simple.
If anyone wants routines to do this, let me know, I have some
that are written in Turbo C that handle direct screen i/o. They
allow you to capture portions of the screen, restore them, change
the color without changing the text, and to write directly to the
screen. E-Mail me...
Greg_d._Moore@mts.rpi.edu