Screen displays are normally set up on an Atari computer by using the PRINT, PLOT, DRAWTO and FILL instructions. This may be adequate in most situations but at some stage you may find that the cursor is out of range, for example if you are using redefined display lists, or that you need extra speed of execution for simple animation sequences. These problems can be overcome by taking advantage of the Atari's memory mapped screen.
In each Graphics mode the screen is split into memory locations which are directly addressable by the POKE and PEEK instructions. The number of locations on the screen is dependent on the Graphics mode in use and each location is assigned a memory address which may vary according to the Graphics mode selected.
The lowest screen memory location is in the top left corner of the screen and its address is contained in the Operating System at locations 88 and 89. The program below will give the start address of the screen memory locations for any Graphics mode represented by 'n'. Simply replace 'n' by the number of the Graphics mode you wish to use.
10 GRAPHICS n:TLn=PEEK(88)+256*PEEK(89)
Subsequent screen locations are numbered sequentially from left to right
across the screen in rows. The contents of locations 88 and 89 alter depending on which Graphics mode is specified and also depending on the amount of RAM that the computer has installed. For this reason it's best to assign the first screen location to a variable and relate any other screen locations to this, e.g.
TL2, TL2+20, TL2+150 etc.
Table 1 shows the total number of screen memory locations for each Graphics mode available from the Operating System. Graphics modes 1 to 8 inclusive have an optional text window which can be suppressed by adding 16 to the Graphics mode number selected. The resultant total number of screen memory locations for each mode is also shown in the table.
Any whole number value between 0 and 255 can be put into a screen memory location by means of the POKE instruction. Precisely what you get on the screen after POKEing a location depends on the Graphics
mode(s) in use. Graphics Modes 0, 1 & 2 give characters from the internal set, whilst the remaining modes give sequences of coloured pixels. The Graphics Modes can be grouped as follows:
GRAPHICS MODE
|
DISPLAY
|
0, 1 & 2
|
Internal Character Set
|
3, 5 & 7
|
Three colour Graphics + background
|
4, 6 & 8
|
Single colour Graphics + background
|
9, 10 & 11
|
Multi-colour/Luminance Graphics (of limited
value in this context)
|
Graphics
Mode
|
Screen
Memory Locations Per Mode Line
|
Number
of Mode Lines
|
Total
Number of Screen Memory Locations
|
With
Text Window
|
Without
Text Window
|
With
Text Window
|
Without
Text Window
|
0
|
40
|
N/A
|
24
|
N/A
|
960
|
1
|
20
|
20
|
24
|
400
|
480
|
2
|
20
|
10
|
12
|
200
|
240
|
3
|
10
|
20
|
24
|
200
|
240
|
4
|
10
|
40
|
48
|
400
|
480
|
5
|
20
|
40
|
48
|
800
|
960
|
6
|
20
|
80
|
96
|
1600
|
1920
|
7
|
40
|
80
|
96
|
3200
|
3840
|
8
|
40
|
160
|
192
|
6400
|
7680
|
9
|
40
|
N/A
|
192
|
N/A
|
7680
|
10
|
40
|
N/A
|
192
|
N/A
|
7680
|
11
|
40
|
N/A
|
192
|
N/A
|
7680
|
TABLE 1
NOTE: The Text Window consists of 4 mode lines of Graphics 0. The start and finish locations for the Text Window will always be
TL0+800 and TL0+959 respectively.
GRAPHICS MODES 0, 1 & 2
These are the modes which utilise the standard character set within the computer's Operating System and each screen memory location is equivalent in size to that required to display a character.
Graphics Mode 0
This mode gives a single colour character set and the
full range of characters available can be shown by the following short
program:
10
GRAPHICS 0:TL0=PEEK(88)+256*PEEK(89):POKE 752,1
20
FOR I=0 TO 255:POKE TL0+I,I:NEXT I
30
GOTO 30
The value to be poked for each character is the same as
the number shown in the Table 9-6 (Page 55) of the Basic Reference
Manual (supplied with the Basic Language Cartridge). To obtain the
Inverse Video of a character add 128 to the value shown in the table.
Graphics Modes 1 & 2
These Modes give the option of the normal character set
in a choice of four colours. Inverse video characters are not available
in these Modes and in order to obtain characters 64 to 127 in Table 9-6
a POKE 756,226 instruction must be used. The range of characters
available can be displayed by substituting GRAPHICS 1 for GRAPHICS 0
(line 10) and TL1 for TL0 (lines 10 and 20) in the program above.
Characters 64 to 127 can be shown by adding the following line to the
program:
15 POKE 756,226
DEMONSTRATION PROGRAM
The accompanying short program 'SPIDER' shows how a
character can be moved around the screen with a joystick by POKEing
values to screen locations. The program is only a demonstration but,
with a little bit of ingenuity, it could be used to form the basis of a
game.
|
|
|
In the next issue of PAGE 6, I'll deal with Graphics
Modes 3 to 8 and demonstrate some other effects which can be generated
with a memory mapped screen.
top