This web page contains the text of articles for owners of the TI-99/4a from Issue 40 TI*MES (Spring 1993). It is of use to users of the TI-99/4a emulators.
This is one of those issues where I sent in my copy to the editor and the magazine was edited by somebody else, who did not have my copy, and inserted a great deal of material from US newsgroup magazines. There were 74 pages with content, which included six pages of a game in tiny print; six pages of 9900 source code for disk i/o access; seven pages on educational modules from a US user group (with an American terminology and culture); and 11 pages of Tips from the Tigercub. Below is a selection of the remaining material...
From the chairmans chair
Well another issue has arrived with you. We must apologise for the slightly late issue this quarter. Unfortunately Alan Baily our Editor has been very ill in Hospital. However with lots of rest and help and some good reading in this book he will most likely be back with us doing the fantastic job that he does. It is no mean feat taking on and collating this little lot. I should know I have just completed this issue on Alans behalf. So from all of us Get Well Soon!!
Last time we looked at Joystick and Randomize routines, this time we will look at the Coincidence of Sprites. TI EXTENDED does have a little routine for doing this called CALL COINC. This takes two Sprites, allows a tolerance and then returns a variable. If the variable is -1 then a coincidence, 0 if not.
You can also do Sprites with Dot Row Dot Column positions with the same tolerance and numeric variable. Last but not least the CALL COINC ALL with numeric variable. Great but not very flexible is it. Now there is a formula that is very useful to the TI programer. Its called the 49 formula. This little baby is expressed as (TO-FROM)*0.49. The TO and FROM being numeric variables.
To demonstrate the 49 Formula here is a little program thats puts a sprite on the screen at a random position and spots it by its placement variables then shoots another to hit it. As can be seen the whole program runs without CALL COINC. Try doing this with COINC and you will find it almost impossible to detect the sprite to a 100%, this program does!!!
100 CALL CLEAR :: CALL SCREE
N(2) :: CALL CHAR(46,"0000001
818") :: CALL SPRITE(#2,94,16
110 FOR N=0 TO 25 :: RANDOMI
ZE :: CALL PEEK(-31808,Y,X) :
: CALL SPRITE(#3,65+N,16,Y/2
+1,X+1) : : CALL SOUND(-60,660
120 CALL POSITION(#3,Y,X,#2
R,C) :: CALL SPRITE(#1,46,16,
R,C,(Y-R)*.49, (X-C)*.49) :: C
130 CALL SOUND(120,110,6) ::
CALL DELSPRITE(#1) :: CALL PA
TTERN(#3,35) :: CALL SOUND(10
0,220,6):: NEXT N :: GOTO 11
[2015 note- line 130 as printed read CALL DELSPRITE(3!0 :: . There was no correction in later issues so I have made a best guess as to what was intended. Line 110 also contained an error and again best guess has been used above!]
Very neat is'nt it. I will now go through the program with you, however I will not explain the simple call Clears and screens etc:
100 sets up Sprite (#2) setting off a ^ symbol across the screen at
a velocity speed of 5 from dot row 180 dot col 1.
110 then starts a for next loop and starts the Call Peek RND routine. (described last magazine) . It then puts Sprite #3 at a random location with some sound, and cycles through the alphabet by adding to ASCII char 65 the loop value of N.
120 then gets the position of #3 and #2.
Sprite #1 is then launched with the Formula 49, with added Sound.
130 then with call sound statements slows the routine for correct timing then
loops to the next letter (For Next Loop remember). After the loop is
done then it starts back at 110 and does it all again.
As you can see not a CALL COINC in sight. What you have been able to
do is some very complex maths with the minimum of memory and with
speed to boot. You can also use this 49 formula in chase the sprite
type situations. Try this:
100 CALL CLEAR :: CALL SCREE
As you can see the line 100 is the setup and starts Sprites #2 and #1. Line 110 does our friend the randomize, adds a bit of sound then locates Sprite #1 with the row col variables from the RND peek with Y/2+1,X+1.
N(5):: CALL MAGNIFY(2):: CAL
11O RANDOMIZE :: CALL PEEK(
31808,Y,X) :: CALL SOUND(60, 1
000-Y*3,4) :: CALL LOCATE(#1
120 CALL POSITION(#2,R,C,#1,
Y,X) :: CALL MOTION(#2, (Y-R*
0.49, (X-C)* .49) :: CALL SOUND(
300,880-Y*3,15) :: GOTO 110
Line 120 then finds the position of Sprite #2 and #1 then Formula 49 is then used in the Call Motion routine on Sprite #2, then a little sound with the value of Y altering the frequency.
The sound call also acts as a delay. If you want to speed things up try the value -60 in the call sound statement in line 110. Then we jump back to 110 and do it all again.
You ask your self, how does one get to the Formula 49 in the first place. Well its simple when you know how. The .49 in fact is a limit control on your sprites. The highest legal velocity for any sprite is 125 (see your manual). You also know that sprites can go from 1 to 256 in both dot row and column however after dot row 193 your sprite is off your screen so you normally use 192-193 as a restraint. (see page 173 of Manual) So anything above that will bloop.
So the formula that places one sprite, at a given location, in motion towards another location is (DOT ROW To, Minus DOT ROW From)*.49,(DOT COLUMN To Minus DOT COLUMN From)*.49, so if we look
at this you can keep your sprites in a set area on your screen. Say you want to keep you sprites in the area dot row 17 through to say 185 and dot columns 17 through 185 then you can adjust the formula 49 to another value like this:-
So the .49 now =.75
With this simple formula in the Call Motion statement the greater the distance the higher the velocity will be. Try adding this new formula to the above program to see it work.
Just to add a little fun to the program we will now put into the routine a joystick control .
Replace the following lines with these.
110 CALL JOYST(1,X,Y):: CALL
MOTION(#1,4*-Y,4*X) : : CALL
POSITION(#2,R,C,#1,Y,X) : : CA
LL MOTION(#2, (Y-R)*.49, (X-C)
*.-49) :: CALL COINC(ALL,A)
120 IF A THEN CALL SOUND(-10
0,-2,8):: GOTO 110 ELSE CALL.
SOUND(-150,630-R-C,15) :: GO
As you note Call Coinc has been used but in conjuction with the Formula 49.
Just to finish off this quarters program hints and tips here is one for you to work out without me telling you how it works.
100 CALL SCREEN(2) :: A=1 ::
FOR N=1 TO 28 :: CALL. SPRITE
)),-6,N*2*A) :: A=-A :: NEXT
110 GOTO 110
T Stevens 1992