Contents of the PAGES.DOC file
OS/2 VIDEO PAGES
This program runs under OS/2 and DOS, and demonstrate the use
of video paging under both operating systems.
The OS/2 programming API did not go overboard in its support of
advanced VGA features, such as video paging, and the VIO subsystem for
IBM ver. 1.0 does not support paging at all.
Also, OS/2 is much more aggressive in its management and structure
of memory than was DOS, not to mention the fact that you cannot directly
address the VGA card's registers at all from ring 3 applications level.
There are two basic barriers to low level video programming under
OS/2: (1) you must get access to the video buffer ram, and OS/2 has
various requirements that you must meet, but ultimately you can do it
from ring 3, and (2) you must get access to the VGA registers, and you
cannot do this from ring 3, but must write a DLL - like a companion prog-
ram to your main .exe file - which runs in ring 2 and which contains
routines that your program can call.
The next thing you have to consider is how aggressive you want
to be in dealing with the OS. Under DOS, or more correctly, under the IBM
BIOS ROM, you get 8 video pages supported with the VGA. I was inspired to
do this program by an article by Abrash, Vol 6.5 Programmer's Journal pg 22
(1988) where he presented a program for DOS that got up to 32 pages with the
VGA ! I wondered how many pages OS/2 would allow, so here it is. Under OS/2
you get none explicitly, but if you are clever, you can get at least 8, and
as this program shows, you can get 15 with a little work.
For various reasons, I was unable to get nearly as many pages out
of OS/2 as Abrash got from DOS. It seems like OS/2 simply reserves parts of
the video buffer to itself, it is not just the tabla rasa that it was under
DOS. It appears that you get 4 usable pages, then 4 unusable, then 4 usable,
I used the same techniques that he used, relocating the text buffer
to 0A000H from 0B800H, getting 64 K ram instead of 32 K, and flipping the
page bit in the miscellaneous register. I got all of these techniques to
work but not as freely as they did under DOS. Thus, some of the program
is devoted to avoiding unusable memory and making this technique look
mor or less practical. I actually don't like writing directly to the
video buffer myself.
This program is presented as a demo of possibilities for page
flipping under OS/2, and not as a full fleged utility.
I left the Codeview material in it, so you can run it thru CVP (if nothing
else, it shows the way CVP handles direct screen writes). I originally had
the code for locking the screen in the program, but it works better if you
do not lock the screen.
One thing I had hoped was that by relocating the video buffer, any
direct screen writes by the program would not 'bleed' over into other screen
groups, a bug that presently affects OS/2 (notably the M editor).
I also replaced the stub loader with Abrash's program (I added an
ESC key exit to his), so you can run this under DOS and see what it looks
like to get 32 pages.
To run this program, copy xpage.dll to the directory that contains
your dll files ( c:\os2 by default ) before running the program, and put the
statement "iopl=yes" into your config.sys. To see the code, have xpage.dll
and pages.exe in the same directory, and load them into CVP with this command
line: "cvp /L xpage.dll pages".
If you have any questions or comments, I can be reached at: