[comp.sys.apple] Screen Windowing on // series

mdavis@pro-sol@crash.UUCP (Morgan Davis) (12/04/86)

Windowing can be done quickly on the Apple // series in 80 columns.  However,
the procedure is a bit bizarre due to the braindamaged video techniques
employed in 80 column mode.

The 80 column screen is comprised of two interwoven 40 column screens.  One of
these 40 column screens is found in the main memory bank of the computer,
starting at $400 on up through $7ff.  The second 40 column screen is located
on your 80-column card in the auxiliary slot in the //e (same idea for the
//c).  It also has the SAME RAM addresses for beginning and end!

You say, how can that be?  Easy.  A softswitch in memory controls which
bank of 40-column video RAM you are working with.  If you write to $c054,
and then write some characters into memory starting at $400, you're storing
data into the MAIN MEMORY bank of video RAM (called "Page 1").  If you
write to $c055, and write characters into the same address, you will be
putting characters into the AUXILIARY MEMORY bank of video RAM ("Page 2").

When doing this, you'll notice that the characters you write will NOT be
placed right after one another.  Instead, they will be spaced out by one
column.  This is because of the way the two banks are woven into one 80-column
display.  One bank owns the ODD NUMBERED columns, while the other bank owns
the EVEN numbered columns.  You're saying, "That's hairbrained!"  And I agree
with you.

The way you work with that scheme is by determining which column you want to
put a character into, and then changing the Page 1 or Page 2 softswitches
accordingly before writing into the $400-$7ff RAM space (or reading from that
same memory).  This is done by dividing the column (0-79) in half, and seeing
if the result is ODD or EVEN (carry bit is 1 if ODD, 0 if EVEN).

Top this off with the NONCONTIGUOUS screen mapping of the video RAM bank, and
you'd just about want to toss your Apple out of the window (the space from
$400-$7ff is not contigious display memory, there are "screen hole" locations
smattered throughout it -- and they shouldn't be disturbed).

So, the simplest way to save the 80-column screen into a buffer and then
restore it, would be to do this:

     1. Select Page 1
     2. Copy all video display bytes at $400-$7ff into your buffer
     3. Select Page 2
     4. Perform Step #2 again (same addresses 'n everything)

        [The 80 column screen data is now saved]

Obviously, restoring the saved screen is just a reversal of the above.

One thing you'll have to watch out for is making sure that you always return
from your subroutines with Page 1 softswitch selected.  If Page 2 is left on,
and you issue any DOS calls, weird things may happen (don't chance it!).
Also, you'll need to familiarize yourself with the way the segmented video
RAM is laid out -- I suggest picking up something like the Apple //c Technical
Reference Manual (a two-volume set) which describes the "screen hole"
configuration.

--Morgan Davis

UUCP: [ akgua hplabs!hp-sdd sdcsvax nosc ] !crash!pnet01!pro-sol!mdavis
ARPA: crash!pnet01!pro-sol!mdavis@nosc