Classic Computer Magazine Archive COMPUTE! ISSUE 21 / FEBRUARY 1982 / PAGE 100

Put Graphics Modes 1 And 2 At The Bottom Of Your Screen

R. Alan Belke
DeKalb, IL

Most of you who are regular readers of COMPUTE! are familiar with the mixing of the graphics modes ("Mixing Atari Graphics Modes," COMPUTE! #6). The only problem is that you can't use a mode past its regular range. That is, if you wanted to use Mode 1 past line 20 or Mode 2 past line 10, you couldn't. So you were stuck putting text you wanted at the top of the screen or in the text window. Until now, that is!

What's The Display List?

First we'll look at the Display List to see what it is and what it does. Figure 1 shows the Display List for Mode 3. You can verify this by running Program 1. Locations 560,561 contain the starting address of the list.

Figure 1.

112, 112, 112, 72, 112, 158, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 66,
        96, 159, 2, 2, 2, 65, 78, 158

The purpose of the list is to tell the computer how to display the information stored in the screen and/or text memories. Let's see how it does this. The first three bytes (112) set up the margin at the top of the screen. How they do this, I don't know. Anyone out there know? Next comes what I call an address byte, (72). In this case, a Mode 3 address byte. (Figure 2 shows what the address bytes are for each of the modes.) This byte pulls double duty. First, it sets the first line to Mode 3. Then it tells the computer that the next two bytes contain the address of the screen memory.

Figure 2.

MODE 0 1 2 3 4 5 6 7 8
ADDRESS BYTE 66 70 71 72 73 74 75 76 77 79

The next 19 bytes (8) set one line each to Mode 3. I call these Mode 3 bytes. You get the value for these bytes by subtracting 64 from the address byte (72-64 = 8). From this, we can deduce that any byte with bit 6 on is an address byte. Also, notice that 19 Mode 3 bytes with the Mode 3 address byte give you 20 rows of Mode 3, which fills the screen up to the text window.

For whatever mode you are in, you will have 1 address byte and the number of rows, minus 1, regular bytes. For example, Mode 7 will have a Mode 7 address byte (72) and 79 regular Mode 7 bytes. Giving you 80 rows. To find out how many rows each mode has, check the "Table of Modes and Screen Formats." It's on the inside back cover of your Basic Reference Manual.

The Last Three Rows Of The Text Window

Now here's the important part. The next byte (66) is a Mode 0 address byte. But, instead of the next two lines containing the address of the Screen memory, they contain the address of the Text Editor memory. This is the start of the text window. Modes 1 through 8 use the Screen memory. Mode 0 uses the Text Editor memory. As you may have already guessed, the next 3 bytes (2) are Mode 0 bytes, giving us the last three rows of the text window. If we were in a full screen format, these last six bytes would not be here.

Now we are to the end of the list. This next byte (65) is also an address byte. But it has a special purpose. It tells the computer that it has reached the end of the list and that the next two bytes contain the starting address of the list. (The same as locations 560,561.)

Before we go on, let me say that the bytes that contain the addresses may vary, depending on the Mode you're in and on the amount of memory you have. All the other bytes will be the same.

So how do we get Modes 1 and 2 on the bottom of the screen? It's simple! Basically, all we do is change the Mode 0 bytes to Mode 1 or 2 bytes. Presto! The computer now displays the Text Editor memory in Modes 1 or 2.

Let's look at Program 2 to see how this is done:

Line 10: sets the margins to 40 characters per line and selects mode 3 with text window. Then it finds the address of the Display List.

Line 20: searches the list for the start of the text window.

Line 30: changes the Mode 0 bytes to Mode 1 bytes.

Line 40–50: the periods denote spaces.

There are a few things of which to be aware. Even though you are using Modes 1 and 2, you're using the Text Editor memory; so the computer thinks in 40 column, not 20 column lines, which means two lines now equal one old line. Here is an example. Suppose we use an empty PRINT statement, planning to leave a blank line. Sorry, it won't work. We would have two blank lines. What we do is put 20 spaces in front of what we want printed on the second line. Also remember that we are using the Text Editor, so PRINT #6 will not work. Try some different things yourself.

What About Mode Two?

Well, that's almost as simple. Mode 2 lines are twice as wide as Mode 1 and 0; so there are only two combinations using Mode 2 possible: two rows of Mode 2 or one row Mode 2 with two rows of Mode 1. We can only use the same amount of room as was originally there. Program 3 uses the latter option from above:

Lines 10–20: same as Program 2.

Line 30: basically the same as in Program 2; only this time we make the second line Mode 2. And, since we use one less byte, we have to move the end of the list one location forward.

By now you should be able to change the text window into any combination of Modes 1 and 2 you want. If you have a program that would work better with the text at the bottom of the screen or the text window as Modes 1 or 2, get to work, experiment! Remember, you're the boss.

Program 1.

10 GRAPHICS 3:A=PEEK(560)+PEEK(561)*256
20 D=PEEK(A):? D;",";:IF D<> 65 THEN A=A+1:GOTO 20
30 ? PEEK(A+1);",";PEEK(A+2)
40 GOTO 40

Program 2.

10 POKE 82,0:GRAPHICS 3:A = PEEK(560)+PEEK (561)*256
20 IF PEEK(A)<>66 THEN A=A+1:GOTO 20
30 POKE A,70:POKE A+3,6:POKE A+4,6:POKE A+5,6
50 ? "........TEAM..........FOUR.LINES.MOE..1"
60 COLOR 2:SETCOLOR 1,10,6:PLOT 17, 1:DRAWTO 17,10:DRAWTO 9,18
70 PLOT 19,1:DRAWTO 19,18:PLOT 20,1:DRAWTO 20,18
80 PLOT 22,1:DRAWTO 22,10:DRAWTO 30,18
90 GOTO 90

Program 3.

10 POKE 82,0:GRAPHICS 3:A=PEEK(560)+PEEK(561)*256
20 IF PEEK(A)<>66 THEN A=A+1:GOTO 20
30 POKE A,70:POKE A+3,7:POKE A+4,6:POKE A+5,65:POKE A+6,PEEK(A+7):POKE A+7,PEEK(A+8)
50 ?"2.LINES.OF.MODE.1"
60 COLOR 2:SETCOLOR 1,10,6:PLOT 17,1:DRAWOO 17,10:DRAWTO 9,18
70 PLOT 19,1:DRAWTO 19,18:PLOT 20,1:DRAWTO 20,18
80 PLOT 22,1:DRAWTO 22,10:DRAWTO 30,18
90 GOTO 90