MAKING IT MOVE 
			
 
			In issue 27 I said that GRAPHICS 0 and GRAPHICS 8 
			were similar. Perhaps you would like some further explanation? Each 
			mode has the same colour attributes, i.e. a border, a background and 
			a point on the background that is the same colour as the background 
			but which can have a different luminosity. Each can be addressed 
			down to a single pixel though GRAPHICS 0 is addressed in a block of 
			8 by 8 to make up a character.
 
			The interesting part is that, if you can address 
			GRAPHICS 8 using a similar block, you can write to this mode as if 
			it were GRAPHICS 0. I have included LISTING 1 as an example of how 
			this can be done. Obviously, being in Basic, it is slower than the 
			operating system but it can come in useful.
 
			The screen pointer (88,89) starts at the top left 
			hand side of the screen. If you POKE any number here it would show 
			as a character in a text mode, or as a coloured point in graphics 
			modes.
 
			Location 57344 is the start of 1024 bytes that hold 
			the character set. Each character is 8 horizontal lines of one byte 
			each. So 1024/8 gives 128 characters. These can be toggled with the 
			inverse key (using an OR operation) to give another 128 characters. 
			For more information, I would recommend the purchase of a good 
			memory map.
			
			The basis of the example listing is to to recognise the character 
			required, look up the appropriate location, get the character data 
			and then produce this data, one line at a time, as a block on the 
			screen. When you RUN the program, you will see the character written 
			quite slowly.
			
			GETTING A MOVE ON
			
			This issue I would like to have a look at movement (ANIMATION to 
			programmers). Movement, without using Player Missile Graphics, comes 
			in two forms. One form, published in issue 25 by Allan Knopp and in 
			the last FIRST STEPS column, is called page flipping. This is where 
			you draw several pages, with slight variations in each, and flick 
			through them very fast to simulate movement. The other method is 
			redrawing which is what we will look at now.
			
			Moving a figure on a screen has to be done in steps. First the 
			figure must be drawn in one location, then drawn (perhaps slightly 
			different) in another position. Normally this is done by drawing the 
			figure in a certain colour on the screen, redrawing in the same 
			position using the background colour (effectively hiding the 
			figure), then moving to another position and redrawing using the 
			first colour. LISTING 2 is a good example of this technique. A 
			variation of this theme is to use the colours of the points to 
			create movement. You may wish to review the last column for details 
			of COLOR and SETCOLOR.
 
			COLOUR CYCLING
			
			Now let's look at how LISTING 3 works. A row of characters is set 
			up, each one using a different colour register. The colours are then 
			shifted from one register to another in a cycle thus making the 
			figure appear to change places. Your homework is to try this out in 
			GRAPHICS 7, making a straight line (remember the robot eyes in 
			Battlestar Galactica, the car in Knight Rider?).
			
			Remember I mentioned memory locations 88 and 89 at the start of this 
			article? One of the reasons is that you can place points directly on 
			the screen using POKE instead of the slower PRINT or PLOT. A few 
			years ago I was given a demonstration of this technique, a program 
			called 'BUGS' written (in Basic) by none other than Les Ellingham! — 
			it was FAST.
 
			USING PRINT
			
			PRINT can, however, still be used to animate the screen with 
			reasonable speed. It is, after all, a form of redrawing. It can be 
			slow and jerky but can have uses in graphic modes. Text modes 1 and 
			2 use upper case characters only, but they use the same SETCOLOR 
			statements as the four COLOR statements. So if we were to print, 
			say, ABCDEFGH, the four registers would be used for ABCD and then 
			repeated for EFGH. Remember last time that I said GRAPHICS 7 uses 
			only four COLOR statements? Well we can in fact print characters to 
			a graphics screen, only thy will show as colour points only rather 
			than letters. One of the reasons for using PRINT in a graphics mode 
			is partly for speed. The character contains the colour register and 
			the point does not need to use PLOT every time. Another good point 
			is that the drawing can be stored as a string and ATARI is renowned 
			for its speed in string handling.
			
			LISTING 4 will demonstrate the speed of using a string instead of 
			trying to PLOT points. I have also used the DRAWTO statement to show 
			that drawing lines is just as fast this way as using a string but I 
			wanted to point out the convenience of a using string — a method 
			which I am sure many of you were not aware of.
			
			LISTING 5 is a complex diagram stored as a string. Try this out 
			using PLOT and DRAWTO and see if it just as fast. Experiment with 
			character strings and different COLOR and SETCOLOR values and you 
			should be able to build up some good graphics of your own.
			
			I hope that this article will stimulate you enough to try out some 
			of your own exercises, you will only become proficient by practice!
 
			Listing 1
              
                | 
            
             |  | 
				 | 
            
             
			Listing 
			2
			
              
                | 
            
             |  | 
				 | 
            
             
			Listing 
			3
			
              
                | 
            
             |  | 
				 | 
            
             
			Listing 
			4
			
              
                | 
            
             |  | 
				 | 
            
             
			Listing 
			5
			
              
                | 
            
             |  | 
				 | 
            
            
            
 
            
			
			top