Classic Computer Magazine Archive ANTIC VOL. 3, NO. 7 / NOVEMBER 1984

the toolbox


Your Atari delivers "The Latest Thing"


The, latest buzzword in the computer world is "windows" -multiple onscreen display areas.  This two part series (to be concluded next month) shows you how to create these multiple display windows with your Atari.  Listing 1, the BASIC demonstration program, runs on all Atari computers of any memory configuration.  Listing 2 and 3, provided for your information, are assembly language source code for the machine language subroutines contained in DATA statements in Listing 1.  You need not type these in to use Listing 1.  Antic Disk subscribers RUN "D:WINDOWS.BAS".

A simple example of a text window is the bottom four lines of a Graphics 1 screen.  If you set the left and right margins for maximum width (with POKE 82,0:POKE 83,39), this window is 40 characters wide by 4 lines long.
   You can use the techniques in Listing 1 to define your own window size, and overlay the contents of any screen with any text you'd like to print.  Once you've assigned your text to a string variable, it's a simple matter to swap the string's contents with a section of screen memory by invoking the two machine-language subroutines with the USR (User SubRoutine) command.  The text strings used in the BASIC demo program, are A$, B$, and D$, and are assigned in lines 140 to 230.  The two assembler routines appear in Listing 1 as DATA statements from lines 420 to 670.
   Listing 2 contains the source code for the conversion subroutine, which is called in the BASIC demo in lines 250, 260, and 270.  The screen display character values, or internal Character Set, are the values for characters actually present in screen memory Since ATASCII and screen display character values are not the same, this routine makes the required conversions.  The BASIC demo program (Listing 1) stores the converter subroutine in the string C$.  If we use DATA$ as the string containing the text to be displayed, the conversion from ATASCII to display characters is as direct as the command:


   Listing 3 is the source code for our Window display subroutine, which is stored in the string W$ in the BASIC demo.  This routine is called using the command:


See lines 360 to 380 in the BASIC listing.
   SOF is the offset distance of the window's top left corner in characters (the size of these units depend on the current Graphics mode) from the upper left corner of our screen.  Using Graphics 0, for example, SOF would be 40 if we want our window to be in the leftmost column of the second line from the top.

LIN is the number of lines of text to be displayed, which determines the window's height.  WID is the width of each line in characters, and LOF is the offset between the beginning of each successive line.  If we want a rectangular window in GR.0, LOF would be 40.  We could also have a slanted window by making LOF 39 or 41 (see Listing 1, lines 340 to 360).  The BASIC demo program demonstrates rectangular as well as slanted windows.
   When using these routines, you must be careful to follow a few simple rules.  The last character in DATA$ must be a heart character.  Type [CTRL][,] to enter the heart at the end of your data display strings.  The only other rule is that you supply the proper number of legal parameters in your USR commands.  Failure to follow either rule may cause your keyboard to lock up, so be sure to SAVE your programs before testing them.
   Listing 1 demonstrates just a few ways it's possible to use windows.  Let us know when you come up with something new you'd like to share.  To help get you started, you might try defining your DATA$ as 960 characters (plus the heart) then flip an entire GR.0 screen from one display to another.  You can use windows to overlay parts of your screen with warning or error messages.  Using a redefined character set, you might also use windows to achieve animation.

Jerry White is an institution in the world of Atari computing and a long-time Antic contributing editor.
   Dave Culbertson describes himself as a "computer person" who is well-versed in both hardware and software and who acts as a mediator between the two often-conflicting worlds.  He's been active in microcomputing for nine years, and is vice president of Custom Electronics, Inc, which produces applications software for Atari and Apple computers.

Listing 1: WINDOWS.BAS Download

Listing 2: WINDOWS2.ASM Download / View

Listing 3: WINDOWS3.ASM Download / View