Antic And The Screen

Most microcomputers on die market today use die same CPU to handle instructions and commands and also display information on die screen. Some systems offer choice of text, text with limited graphics, or high-resolution graphics. The ATARI microcomputer has a video microprocessor called Antic which handles the screen display. It has its own set of instructions that are different from the 6502 instructions, its own program, and data. This makes it possible to display several different modes on the screen at the same time. By using interrupts, you can display more colors than BASIC normally allows.

To understand the graphic capabilities of the Antic chip, you must first understand how a television screen works. An image is drawn on the screen by means of a raster scan: A beam starts at the upper left corner of the screen, and moves across the top of the screen. When it reaches the right side of die screen, it is turned off and returns to the left side of die screen. It is also lowered one line below the line just traced. It continues this pattern until it reaches the bottom of die screen. The beam will shut off and return to the upper left corner of die screen. The period of time it takes the beam to return to the left side of the screen is called the horizontal blank. The time needed to return to the upper left corner is the vertical blank.

The ATARI displays information using 192 scan lines. Each mode uses from 16 to 1 scan line(s). In mode 0 there are 24 rows on the screen. Each character stands eight scan lines high (8x24=192 scane lines).

The Antic chip must be able to determine which modes are used in a program. To do this, it uses a display list. In direct command, type: ? PEEK(560)+PEEK(561 )*256 . This location (560-561) is a two-byte address that stores the beginning address of the display list. Run Listing 18-2.

The numbers printed vertically on your screen are instructions for the Antic chip. The numbers should read:

112 112 112

64* may vary 156* may vary 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

32* may vary 156* may vary

Decimal Code

Assembly Language Listing

104

PLA

;Pull the accumulator

off the stack

162

LDX #4

;Load the index X with 4

4 160

LDY #0

;Load the index Y with 0.

0 177

LDA (205),Y

;Load the accumulator

205

with the contents of the

memory location that is

arrived at by adding the

contents of index Y to

the memory location

contains in location

205-206

145

STA (203) ,Y

;Store the number in the

203

accumulator in the

address arrived at by

adding the contents of

the index Y with the

contents of locations

203-204

200

INY

;lncrement the index Y

208

BNE

;Branch if the index Y

249

is not 0 backwards 6 bytes.

230

INC 206

;Add one to the number in

206

location 206.

230

INC 204

;Add one to the number in

204

location 204

202

DEX

;Decrement the index X

208

BNE

;Branch if the index X

242

is not 0 backwards 13 bytes.

96

RTS

; Return to BASIC

Fig. 16-3. Assembly Language Listing for Moving Character Set from ROM to RAM.

Fig. 18-4. Flowchart for assembly language subroutine that moves character set from ROM to RAM.

puto in index y get one byte from rom address add one to ram high order address store it in ram address decrement index x increment y index return add one to rom highorder address

(start)

pull the accumulator put 4 in index x

This display list contains 32 bytes. The first diree numbers (112) are blank lines. Because there is an overscan on most television sets, the first 24 scan lines are blanked out. The next

Decimal Code

Assembly Language Listing

72

PHA

;Push the contents of the

accumulator on the stack.

169

LDA #88

;Load the accumulator with

88

88.

141

STA 54282

;Store the contents of the

10

accumulator in this location

212

- wait for horizontal sync.

141

STA 53272

;Store the contents of the

24

accumulator in the color

208

register.

104

PLA

;Put the number that was

stored on the stack back

into the accumulator.

64

RTS

; Return

Fig. 18-5. Assembly Language Subroutine that adds more colors to screen.

number, 66, is a combination of two numbers. 64 tells the Antic chip to load its memory scan counter widi the following two numbers. By adding two to it, we tell it to use graphics mode 0. The next two numbers may vary, and contain die starting location of the screen. The first number is the low order address, the second number is the high order address. This address should be followed by 23 twos. Each two represents one row on die screen in mode 0. The 65 is another combination instruction. 64 means to jump to die location in the next two bytes when there is a vertical blank. Add one for a jump address. The next two numbers are die address the Antic chip will jump to—the beginning of the display list. Antic will continue with diis display list until it is changed.

There are two important features about this display list. Because you can POKE numbers into it, you can change your screen display for any area of memory. You can even alternate between two screen display areas for animation or special effects. Also you can change the mode of one display line or several display lines and create multi-mode displays.

If you have less than 192 scan lines, your screen display will be shortened by that number of lines. Display lists must not cross a IK boundary. If you have no choice but to cross a boundary, you must use a jump instruction or the Antic chip could get confused and never access the last part of your display list. One other problem arises with BASIC. If you try to print on the screen in a

Listing 18-2. Display List

10 rem listing xviii.2 20 rem display list

30 rem by l.m.schreiber for tab books 40 di splay=pei!ek (560 ) +peek < 561) *256 j rem fi nd the beginning of the display list 50 for x = display to display+31* ? peek<x)j next xjrem print the display list position that would normally be out of range for the cursor, BASIC will refuse to print there. Mixing 20 column modes with 40 column modes will move the position locations also.

Listing 18-3 mixes three modes to give you a varied print in the display message.

Line 40 finds the beginning of die display list. The display list address, a two-byte address, is stored in locations 560 and 561. Multiply die second byte by 256 and add it to the first byte to arrive at the address.

Line 50 saves the screen address. Since we will be using mode 0 for most of the screen display, we do not have to recalculate the screen area. The fifth and sixth numbers in die displaylist are the screen address.

Line 60 shuts off die Antic chip (since the Antic chip is constantly accessing die display list, we cannot change values in it while the chip is on). Memory location 559 tells Antic whether it should be working or not.

Lines 70-190 change die display list. We want to display one line in mode 1 and one line in mode 2. First decide which lines to change. The numbers in die display list must reflect tliis change.

Line 70 POKEs 112 into die first three memory locations of die display list. (Remember, the display list address is the first memory location, so die first three locations are 0 to 2.)

Line 80 POKEs the command that tells Antic die next two bytes contain die screen address and the mode die first line on the screen is in.

Line 90 POKEs die screen address. This program will reuse the address previously stored diere.

Lines 100-110 POKE a 2 into die next six locations. This tells Antic to use mode Ofor diese lines of the display.

Line 120 POKEs a 6 into die next location. The eighth line on die screen is now in graphics mode 1.

Lines 130-140 POKE a 2 into die display list for seven more lines in mode 0.

Line 150 POKEs a 7 into the next location. This makes the sixteenth line on the screen mode

Lines 160-170 POKE a 2 into the remaining locations in die display list. The rest of the screen will be in mode 0.

Line 180 POKEs a 65 into die next location. This instruction tells Antic to jump to die address contained in die next two memory locations and start die display list instructions again after a vertical blank.

Line 190 POKEs die display list address into the next two memory locations. Since we did not move the display list, we can reuse the address in locations 560 and 561.

Line 200 turns the Antic chip on by POKEing a 34 into location 559.

Line 210 turns the cursor off and sets the background color for mode 0 to black.

Lines 220-230 clear die screen and print a message in die two lines in modes 1 and 2.

Line 240 loops until the break key or system reset is pressed.

If you press die break key and list die program without pressing the system reset key, die screen display will be the same as it is for the program. Your listing will appear in three different modes and die sections of the screen between mode 1 and mode 2 will appear off. Instead of the lines starting at the left side of the screen, they will begin in die middle of die screen, because the

10 rem listing xviii.3

20 rem changing the display list

30 rem by l♦m♦schreiber for tab books

40 display=peek(560)+peek<561 )*256jrem fi nd the beginning of the display list

>:rem save the screen address

60 poke 559,0 j rem shut off the antic chip

70 for x=d i splay to di sf'l ay+2 j poke x,112i next x trem blank lines

80 poke display+3,66jrem mode 0 and scree n address follows

90 poke displays, scl_: poke l'hsplay+5 ,sch 100 for x=di spl.ay + 6 to display + 11 j rem the re are 6 more modes 0 lines 110 poke x,25 next x

120 poke display+12,6 j rem this line is mo de 1

130 for x=display+13 to display+19 irem 7

lines of mode 0

140 poke x,2 j next x

150 poke display + 20,7 s rem mode 2

160 for x~display+21 to 27 irem the rest i s mode 0

170 poke x,2 i next x

180 poke displ.ay+28,65:rem jump and wait for vertical blank

190 poke display+29,peek(560)j poke displa y+30,peek(561)

200 poke 559,34:rem turn antic back on

210 poke 752,1¡poke 710,0¡rem turn off cu rsor and set col.ur to black

220 ? ">clear>"¡position 2,7j? "changing"

230 POSITION 29»14J? 'modes'

240 goto 240

computer thinks the entire screen is displayed in mode 0. The lines in mode 0 are 40 characters long. When we changed the eighth line to mode 1, the computer will still count to 40 when displaying that line. This causes a wrap-around to die next line. Every line following is off by 20 characters. The situation rights itself when we change the sixteenth display line to mode 2. Also, because of this wrap-around effect, the first position in line 16 is not 0, but 20. BASIC will also produce the display on that line as if it was row 14 rather tiian 15.

Once you have a good idea of how the screen will be displayed when the modes are mixed, you can develop some interesting effects.

0 0

Post a comment

  • Receive news updates via email from this site