From: mduffy@aludra.usc.edu (Michael Duffy)
Newsgroups: rec.games.programmer
Subject: Re: vga mode 13
Date: 18 Nov 1992 16:58:23 -0800
Organization: University of Southern California, Los Angeles, CA
NNTP-Posting-Host: aludra.usc.edu

In article <1992Nov17.121513.11999@bsu-ucs> 00rbspelman@leo.bsuvc.bsu.edu writes:
>In article <1992Nov13.152904.1806@ms.uky.edu>, carld@ms.uky.edu (Carl Lafferty) writes:
[....]
>> Anyway.  I was wondering if anyone can tell me how to page flip using
>> mode $13 on the IBM vga compatibles.  Any help will be appreciated.  
[....]
>> Carl Lafferty
>
>	Well, there is ALWAYS a way around this one, only I don't quite know
>what it is at the moment.  Officially, you cannot flip pages while in mode 13.
>It is not supported by the chip?  If you are using some form of basic which
>supports mode 13, you can dimension an array, and assuming that your pictures
>will be similar in backround, you might use GET/PUT and a few DRAW statements
>to manipulate things to your liking.  Otherwise I would say try to set aside 
>enough memory to hold an image in mode 13, then direct the VGA card to get
>the picture information from there instead of from its own memory.  
>
>	The major problem this causes is with memory.  I don't remember offhand
>how much memory mode 13 takes up, but I am sure it is at least 256k, probably
>substantially more due to the higher resolution and color options.  Good luck..
>
>Robert B. Spelman
>Ball State University
>Muncie, IN
>00RBSPELMAN@LEO.BSUVC.BSU.EDU
> 
Bzzztt.  Wrong. Thank you for playing........  Hmmm... If only I had a FAQ for
this group to throw around.....

Mode 13 is arranged so that it takes up 64,000 bytes (just short of 64k) in 
display memory.  The way the VGA card flips pages is to set a new address for
it's first pixel (the upper left hand corner of the screen).  As a cruel joke,
the designers of the VGA card only allow this address to be in the first 64k
of display memory.  Hence, Mode 13 takes up too much of the first 64k to have
a second page.  Also, VGA cards can only display stuff that is in display 
memory; you can't direct it to get info from regular memory.

You do have a few options though:
 1) Use an array in standard memory the size of your screen and write screen
    data to that instead.  Of course you'll have to write all of your own 
    graphic primitives to write to the array instead of display memory.  Once
    all your info for the frame is in the array, wait for a verticle retrace
    and throw the buffer into display memory with nothing short of assembly 
    language (I SUPPOSE a higher level language could work, but it depends on
    how well your compiler writes code.)

 2) Use a 16 color mode which allows more than one page of display memory.
    Since on a VGA the registers that mimic the EGA's palette are transparent
    to the VGA's 256 color registers, you can have a palette of 16 colors
    out of 256Kcolors.  (On an EGA, you still have 16 out of 64, though.) 
    Write your info to an undisplayed page, wait for a vertical retrace, and 
    flip pages.  

 3) Use a tweaked 256 color mode that allows multiple pages.  I won't go into
    the tweaked modes now, since I would only be repeating info that has been
    on this group for the past year or so.  Observant people will know what 
    I'm talking about.  No tweaked mode libraries exist for BASIC as far as I
    know.  Move up to C or Pascal (boy I'm mean!).

 4) Which you should do anyway.  Buy a book on EGA/VGA.  Read it, study it,
    come here if you have questions about it.

Later all,
Mike Duffy (mduffy@aludra.usc.edu)