For this edition we will look first at speeding up joystick routines. If you move the joystick a number is put in the corresponding joystick register and is normally read by a line such as
10 IF STICK(O)=14 THEN ?"UP"
One feature of Atari Basic is that if the conditional (IF) statement is not true then the rest of the line is not carried out. This will include
separate commands on the line. For example, in the following line, if you do not push the joystick up, the SOUND command will not be implemented.
20 IF STICK(O)=14 THEN ? "UP": SOUND,0,100,10,10
As there are eight directional and a neutral position for the joystick this could mean nine
separate lines to read the joystick fully since you cannot put them all on one line. We can use less lines however by using Boolean Algebra.
Don't panic! Boolean Algebra is very simple, a statement is either true or false. Start by substituting a letter for STICK(O) i.e. S=STICK(O) and then check to see if its value is correct. If S=14 then 1 (true) is returned, if not then 0 (false) is returned. In this way we can look at several joystick positions at once. Only one of them can be true because we can only move the joystick in one direction at a time. In the following example, if the stick is moved in any of the three directions to the right, then X is increased. The values for the right positions are 6 for up right, 7 for right and 5 for down right, so if X equals one of these we add one to the value of X.
10 S=STICK(O):X=X+(S=5)+(S=6)+(S=7)
Similarly, we can decrease the value of X by the following line
20 X=X-(S=9)+(S=10)+(S=11)
The reason for the plus signs is that the statement will total up the value of S and subtract this from X. If you used minus signs, then you would be subtracting a minus number, which is the same as adding it. Try the following lines to test for Y.
30 Y=Y+ (S=5)+(S=9)+(S=13)
40 Y=Y-(S=6)+(S=10)+(S=14)
50 ?
"X=";X: ? "Y=";Y
80 GOTO 10
A better way is to use S=PEEK(632) instead of STICK(O) because some locations display either a
0 or any number. A good way to test this is by using the NOT statement. For example, location
644 is Stick TRIGger(O) and is zero when the trigger is pressed, 1 when it is not.
The following lines can be used.
50 IF NOT PEEK(644) THEN ?
"PRESSED"
60 IF PEEK(644) THEN
? "NOT PRESSED"
Whatever made you think mathematics was hard?
I have had a few queries about the speed of the 810, and especially
about speed check programs in American magazines. The rated speed is 288 r.p.m. If you use an American program to set your drive at this speed, you will have trouble loading. This is because the speed is controlled by a clock that is locked to the mains frequency and the Americans use
60Hz whereas we use 50Hz. A correction is needed - Speed=288/50 (revs per Hz)*60 - so that you set the drive speed to approx 345 when using an American program.
(Note the speed check program on PAGE 6 Utility disk 3 has been amended so that you should set to 288 with this program. Ed)
I have wired in a write protect switch (courtesy of the Editor and Alan Haskell) on my 810 and have found it well worth the effort.
I have also added a power light and busy switch to my 410. Perhaps Les can be persuaded to start a customising column in PAGE 6, if you send articles in that is!
Stan Fallaize sent me some examples of his 1020 printer, which came out very clear.
His only problem is the 'abysmally inadequate' instructions. If any reader owns a 1020 perhaps they could contact Stan at 1a, Cranleigh Drive,
Leigh-on-Sea, Essex, SS9 1SX.
Your letters have forced me to look at areas I have not tried for many months and for this
I am grateful so keep sending in those questions, no matter how trivial they may seem, but please include a s.a.e. and do not worry if you do not hear straight away.
I have a lot to do and it may take several days to reply but I will get there eventually!
Write to Mark at BAUG Software, P.O.Box 123, Belfast, BT10 ODB
top