In the last issue, I introduced the concept of the memory mapped
screen and dealt with Graphics 0, 1 and 2. In this article I shall
look at Graphics Modes 3 to 8 and show a simple animation sequence
achieved by using POKE statements.
When values between 0 and 255 are POKEd into screen locations using
Graphics Modes 3 to 8, a pattern of coloured pixels is produced at the
selected screen location. Graphics Modes 3, 5 and 7 allow three
foreground colours plus background whilst Graphics Modes 4, 6 and 8
allow only one foreground colour plus background. The colours obtained
are the normal default colours for each mode but they can be
manipulated by using the SETCOLOR command or by POKEing the relevant
COLOR register.
GRAPHICS MODES 3, 5 and 7
These are the '3 colour' Modes and if you compare the horizontal
resolution from the table at the back of your Basic Manual with the
Screen Memory Locations per Mode Line shown in Table 1 of the first
part of this article, you will see that each screen memory location is
equivalent to a horizontal block of 4 pixels.
|
|
![](../download.gif) |
Program 1 shows the resultant display for each POKE value between 0
and 255. Graphics 3 has been used for the display, but similar effects
occur with Graphics modes 5 and 7.
A coloured reference chart can easily be prepared using this
program and 1 have found mine invaluable for programming animation
sequences.
GRAPHICS MODES 4,6 and 8
These are the 'single colour' Modes and each screen memory location
is equivalent to a horizontal block of 8 pixels. The range of POKE
values, 0 to 255, is again available but this time the resultant
'block' is a representation of the binary equivalent of the number
POKEd. Each 0 becomes a pixel plotted in the background colour and
each 1 becomes a pixel plotted in the foreground colour. Figure 1
should make things a little clearer.
![](images/page_10a.gif)
Program 1 can be amended to a 'single colour' mode by substituting
GRAPHICS 4 for GRAPHICS 3 in line 10 and TL4 for TL3 in lines 20 and
40.
Graphics Mode 8 is the highest resolution Graphics Mode available.
The pixel size is so small that multicolour effects are possible by
careful selection of the pixels to be plotted. This process is known
as artifacting and is used quite extensively in America although it
doesn't work very well on U.K. televisions. For the purposes of this
article Graphics 8 can be considered as a 'single colour' mode.
GRAPHICS 9, 10 and 11
These are the additional modes available with the GTIA chip and
each screen memory location is equivalent to a block of 2 pixels. The
use of screen memory locations is limited in these modes due to the
size of the pixels and animation techniques are best executed by use
of the colour registers, particularly in Graphics 10.
![](images/page_10b.gif)
DEMONSTRATION PROGRAM
Program 2 uses a modified Graphics 6 screen to display six 'cities' together with a landscape which utilises the text window. The last seven lines of the Graphics 6 display have been replaced
with Graphics 7 in order to record the cities and the landscape in
different colours.
Twenty randomly selected laser-bolts are produced and if a city is struck, the city explodes and is then rebuilt. A score of 555 points is awarded for each hit and any necessary updating of 'score' and 'missiles remaining' is carried out before the next missile is launched. When all the missiles have been fired, a high score is shown and an invitation to re-run the program is displayed.
Every item in the screen display with the exception of the laser-bolt is produced by POKEing to the screen. Although the majority of the routines are reasonably straightforward, the following notes may help.
1. Screen Memory Locations for the Cities
Figure 2 shows the screen memory locations for the last line of Graphics 6 and the first line of Graphics 7 in the screen display used.
The numbers shown are the numbers of screen memory locations from the top left of the screen (TL6). Locations 1466, 1470, 1474, 1484, 1488 and 1492 are the start locations for the cities and they are held in the array
C(1-6). Locations 1443, 1445, 1447, 1452, 1454 and 1456 are used to check whether a city has been hit and are held in the array CHK(1-6).
2. Animation Sequence
The animation sequence for the city explosion is shown in the series of Figures 3(a) onwards. Each phase of the explosion is drawn on a 7 by 8 grid. The eight horizontal pixels are actually made up of two blocks each of four pixels width. The values shown by the side of each figure are
the POKE values to obtain the pattern of pixels shown in the default colour 1
'yellow/green'. The SETCOLOR statement in line 40 of the program changes this colour to the 'purple/blue' colour of the city. The expressions containing XP in Figure 3(a) relate
to the explosion routine in lines 1060 to 1160.
3. Score, Hi-Score and Missiles Remaining
The variables S, H and M (line 30) contain the start addresses for the score, hi-score and missiles remaining screen memory locations. The arrays SC(1-5),
HSC(1-5) and M(1-2) contain the actual numerical values. The mechanics of updating these values is a little complicated but should be easier to follow if you know that the first element in the array contains the units, the second element the 10's and the third element the 100's and so on.
![](images/page_10c.jpg)
![](images/page_10d.jpg)
The routine in line 2600 checks for a new hiscore by calculating
the difference between the existing hi-score and the new score. If the
difference is less than 0 then a new hi-score exists.
I hope that at least parts of this article will be of value to you
and will stimulate enough interest for you to experiment and include
similar effects in your own programs. You will find that a little time
spent with pen and paper beforehand will pay dividends when planning
animation sequences and working out the position of screen locations.
|
|
![](../download.gif) |
top