MODE MIXER
Multiple graphic modes on one screenby KARL E. WEIGERS
Mode Mixer is a utility program for easily creating custom display screens that use multiple graphics modes., and then saving them to disk for later use in your own programs. Written in BASIC, Mode Mixer requires a disk drive and will run on all Atari computers with 32K, depending on screen use.
DISPLAY LIST
The Atari's video display is created by
a special microprocessor chip called ANTIC. (Yes, as in the title of your
favorite magazine.) ANTIC can present information in 14 different graphics
modes, six for text and eight for plotted graphics.
Only nine of these modes are available directly from BASIC
on the old Atari 400 and 800 computers, but 13 of them can be accessed
in BASIC with the XL models. The graphics modes differ in their horizontal
and vertical resolution, number of colors shown, and amount of memory consumed
(Table 1).
The program which tells ANTIC what kind of display to
show is called a "display list". A nice introduction to display lists and
mixed-mode principles is found in "Display Lists Simplified" (Antic, Feb/Mar
1983). "Unlocking the 56 Graphics Modes" (Antic, Sept. 1984) illustrates
all these modes and provides more information about the Atari's video display.
A BASIC graphics call will only give you a screen of one
mode (with the exception of windows). To construct a mixed-mode display,
you must create a display list to tell ANTIC how many "mode lines" of each
desired graphics mode to show. The resulting screen is made up of several
horizontal bands or segments, one band for each block of lines in a particular
graphics mode.
The display list also contains some other information,
and a few tricks have to be played to print or plot correctly in the different
segments. For each graphics mode, one mode line consists of a specific
number of horizontal TV "scan lines", ranging from 1 for ANTIC mode 15
(GRAPHICS 8) to 16 for ANTIC mode 7 (GRAPHICS 2). A complete screen must
contain 192 scan lines. Keep these numbers in mind as you use Mode Mixer.
USING MODE MIXER
Type in Listing 1, check it with TYPO II, and SAVE a couple of backup
copies. RUNning the program shows you a menu. Just press a number key to
choose a menu selection; it is not necessary to press [RETURN]:
1. Create a New Display: Begin with this option. You will see
a screen which prompts you to enter the ANTIC graphics mode (2-15) for
the first segment. Then you can specify the number of mode lines for that
segment. Continue this process for all the segments in your display. The
table at the top of the screen keeps a running description of your display
as you compose it. Keep an eye on the number of scan lines remaining, which
goes down each time you describe a new segment. The goal is for this number
to be zero when your display is complete.
You can enter up to 16 segments per display, combining
the available graphics modes any way you like. When prompted for a graphics
mode, enter the ANTIC mode number from Table 1, not the usual BASIC graphics
mode number. To cancel an entry, enter zero for the number of mode lines.
When you have completed the description of your display, and wish to return
to the menu, enter zero for the next mode number.
Notice that selecting option 1 at the menu erases forever
any display already in memory.
2. Change the Current Display: Use this option to modify the
display currently in memory, whether you just created it or loaded it from
the disk. You will be prompted for the segment number to modify, and then
for the new graphics mode and number of lines.
If the number of scan lines remaining is greater than
zero and the number of segments in the display is less than 16, then you
can add new segments to the bottom of the display When prompted for the
segment number, just enter the number one greater than the last segment
number already in the display. Also, you can erase a segment by setting
the number of mode lines for that segment to zero.
When you have finished editing the display, enter zero
for the segment number to change. You will return to the menu.
3. See the Current Display: This function actually generates the display list from your description of the mixed-mode screen. The TV screen will be black briefly while the calculations are done, and you will hear a tune reminiscent of Woody Woodpecker when the computer is done. At that point, you will see the mixed-mode display. Admittedly, it isn't very interesting: just bands of blue (for ANTIC modes 2, 3, and 15) and black (for all other modes). In fact, you may not see anything at all. Rest assured that all is well, however. After you hear the tune, press any key to return to the menu.
4. Save Current Display on Disk: This part of Mode Mixer writes
a program for you and stores it on the disk. First you will be asked to
supply a file name. Use any legal Atari disk file name, without extender.
Unless otherwise specified, Mode Mixer assumes you mean disk drive one,
and it assigns an extension of ".DSP" to the file name you give. If you
try to save the display before you viewed it with menu option 3, you will
go through step 3 anyway.
The resultant file will be a BASIC program, stored in
LISTed form. We will talk later about how to use this program.
5. Load a Display from Disk: Here you can retrieve a display
from the disk for further editing. MODE MIXER shows you a list of all the
files with extension "DSP" and you type the name of the file you wish to
load. Enter a zero if you decide not to load anything after all.
It takes several seconds for the program to read the file
and reconstruct the display description. When this process is complete,
you will be at the "Change the Current Display" screen. Notice that using
option 5 replaces any existing display in memory with the one you load
from the disk.
6. Done With This Program: Choose option 6 to leave Mode Mixer and return to BASIC.
STORED DISPLAYS
To use a stored display, type NEW to clear out any program already
in the computer's memory, then type ENTER "D:filename.DSP". You can now
RUN this program to recreate the display as you described it to MODE MIXER.
This program consists of several parts:
1. Line 10, which calls a subroutine at line 30000.
2. Several statements which set up the various segments in your display. Each begins with a POKE 87,n command, where n is a BASIC graphics mode number.
3. An END statement at line 29999.
4. A block of statements beginning at line 30000 which set up the display list needed by your mixed-mode screen.
5. A subroutine beginning at line 31000 which controls memory allocation
for each display segment.
The point of all this work so far is to help you get some
fancy displays on the screen. You accomplish this by thinking of each segment
as a separate little screen. Following each of the POKE 87,n statements
you can insert any appropriate text or graphics display commands. For text
modes (ANTIC 2-5) use POSITION and PRINT #6; statements.
In the graphics segments (ANTIC 6-15), use PLOT and DRAWTO
commands. The upper left corner of each screen segment is location 0,0.
Be sure not to plot or print outside the allowable horizontal and vertical
boundaries of a segment, based on the number of mode lines you have in
each segment.
You can easily combine a program written by Mode Mixer
with any other BASIC program. Use the ENTER command to retrieve the display
program file from disk and merge it with another program already in memory.
Remember that line numbers from an ENTERed file replace any statements
with the same line numbers in the existing program when you do a merge
operation.
AN EXAMPLE
Listing 2 is a sample program written by Mode Mixer. The display specified
has six segments: 4 lines of ANTIC mode 6; 4 lines of ANTIC 2; 20 lines
of ANTIC 14; 4 lines of ANTIC 5; 20 lines of ANTIC 15; and 6 lines of ANTIC
10.
Type in Listing 2 and LIST it to disk. Next, type in listing
3 and SAVE it. With listing 3 in memory, ENTER Listing 2 to merge the two
programs, then RUN it to see a nice demonstration of the kind of complex
displays you can produce using Mode Mixer and a bit of your own creativity.
NOTE: Press [SYSTEM RESET] after running any program created using Mode
Mixer.
OTHER TIPS
You can change the color registers as usual in a program with a mixed-mode
display. (Atari Color Graphics or Atari Graphics and Arcade Game Design,
available from the Antic Catalog, fully describe what the different color
registers do in each BASIC graphics mode.) Using display list interrupts
(see “More Interrupting" in Antic, Dec. 1983) to get different colors in
different segments will help create truly dazzling displays.
To get a uniform background color for displays in which
ANTIC modes 2, 3, or 15 are mixed with the other modes, use a SETCOLOR
2,H,L statement, where H and L are the hue and luminance of the desired
background color (0,0 is the default). Unfortunately, this also makes any
graphics which use a COLOR 3 statement invisible.
I haven't forgotten about the three GTIA graphics modes,
BASIC modes 9, 10, and 11. These all use the same display list as ANTIC
15, so just create a segment with mode 15 with Mode Mixer. Then change
the POKE 87,8 statement for that segment to a POKE 87,9 (or 10 or 11, depending
on the GTIA mode you want). You will need to use display list interrupts
to alter the GTIA location at $D01B for only the appropriate segments.
The XL computers have a BASIC mode number for all ANTIC
modes except 3. Programs written with Mode Mixer will work fine on the
XL computers. However, you may wish to change the "n" in the POKE 87,n
statements for segments of ANTIC 4, 5,12, and 14 to the appropriate BASIC
mode from Table 1.
Line 15 of Listing 3 (POKE 752,1) prevents stray cursors
from appearing when printing in text segments of a mixed mode display
Table 1
Atari Graphics Modes
ANTIC BASIC Scan Lines/
Mode Lines/
Mode Line Screen
2 0
8
24
3 NONE
10 about 19
4 12(XL)
8
24
5 13(XL)
16
12
6 1
8
24
7 2
16
12
8 3
8
24
9 4
4
48
10 5
4
48
11 6
2
96
12 14(XL)
1 192
13 7
2
96
14 15(XL)
1 192
15 8
1 192
Table 2
Variables Used in Mode Mixer
INC - increment counter for number
of bytes per segment
MODE - ANTIC mode for each segment
LINES - number of mode lines for each segment
SLPER - number of scan lines per mode line in
each ANTIC mode
BPER - number of bytes per mode line in
each ANTIC mode
BAS - BASIC graphics mode number
to use for each ANTIC mode
B$ - general use string variable
A$ - general use string variable
FNAME$ - filename for loading or storing display
BL$ - string of blank characters
OFF - value to disable a TRAP statement
NO - line number of subroutine
to make error sound
MEMORY - line number of a subroutine to set screen
memory locations for a segment
LOCS - line number of a subroutine to calculate
location of screen memory and display list
SPACE - line number of a subroutine to wait for
space bar to be pressed
DL - starting location of display
list
MEM - starting location for screen
memory
LMEM - low byte of starting location of
screen memory
HMEM - high byte of starting location of
screen memory
BYTE - number of bytes of screen memory
in a segment
CH - general input variable
NSEG - number of segments in a display
GRA - ANTIC mode of current segment
NUM - number of mode lines in a current
segment
LEFT - number of scan lines left in this
display
A - general input variable
CT - counter for number of
bytes in display list
OSMODE - mode number of a segment as read from disk
MAX - BASIC graphics mode number
of segment in the display with the greatest screen memory requirement
FOURK - next 4K boundary after beginning of screen
memory
Y, I, J - variables for loops, offsets, temporary calculations
LN - line number of statement
in file being saved to disk
Table 3
Mode Mixer Program Take-Apart
Line Numbers
Function
1-99 initialize
variables and arrays
100-230 menu
500-520 subroutine to make error
sound
550-560 subroutine to set new screen
memory locations
600-610 subroutine to calculate screen
memory locations
625-635 subroutine to pause until
space bar is pressed
900-970 subroutine to set up display
create! change screen
999-1070 create a new display; define mode
for a segment
1080-1100 define number of mode lines for a segment
1110-1140 calculate number of scan lines left,
update table
1999-2005 change current display routine starts
here
2010-2040 show current display description
2050-2165 input segment number to change and
make changes
2170-2190 update table describing display
2999-3080 load display from disk; show displays
on disk
3090-3170 get file to load, open file
3180-3290 figure out no. of segments & display
list bytes
3300-3400 figure out no. of mode lines per segment
5999-6050 see the current display routine starts
here
6100-6140 figure out maximum memory requirements
mode
6145-6290 create display list in page 6
6320-6360 show display, play tune, wait for keypress
6370-6380 branch based on whether user wants
to store display
6999-7000 save display on disk routine starts
here
7010-7080 get filename and open file
7100-7420 write statements to file which will
recreate display
7500-7520 error handling for bad file open
Karl Wiegers is a frequent contributor to the pages of Antic. His most recent work was "Touch Tablet Cursor" seen in our January 1985 issue
Listing 1 MODEMIX.BAS Download
Listing 2 MIXDEMO.DSP Download
Listing 3 MIXADD.LST Download / View