COMPUTE!'s TI Collection Volume One
COMPUTE!'s TI Collection Volume One
'- COMPUTE!'s
•
'-
COLLECTION
VOLUME ONE
•
'-
,
'-
,
'-
ISBN 0-942386-71-X
1098765432
COMPUTE! Publications, Inc., Post Office Box 5406, Greensboro, NC 27403, (9 19)
275-9809, is one of the ABC Publishing Companies, and is not associated with any
manufacturer of personal computers. TI-99/4 and TI-99/4A are tradema rks of Texas
Instruments, Inc.
Contents
Foreword .............. . ... .. ..... . . , .. . .. . ............ v
v
'--
'--
L
I
TI Features
_____ c. Regen.
,,
1 ••
.
effects. Here is a sample using just one tone:
FOR N=S00 TO 88. STEP 2.
..
CALL SOUND( - 99.N,2)
12. NEXT N
4
_ _ _ _ _ _ Getting Started
able, BL, but the TI-99/4A knows you are using two variables.
You also do tlot have to worry about embedded reserved
words in variable names.
Documentation. Two excellent manuals aTe included with
the computer. One teaches you programming in TI BASIC.
The manual is very easy to understand, and a person with no
previous computer experience can Jearn to program with this
book. Also included is the User's Reference Manual, which may
cost over $15 for other computers. The reference manual.
which is in loose-leaf form, includes aU the commands along
with explanations and sample programs.
Plug-in modules. The easiest way to use the Tl-99/4A is
to insert a command module which contains a program. The
modules actually add memory to the computer while they are
being used. Unfortunately many of the very best modules are
difficult to find or even completely unavailable.
Speech. Even though this feature is not built in, I'm going
to include speech in this list of unique features of the TI~
99/4A because it is very easy to use . The speech synthesizer
is a small box that attaches to the side of your console.
16-bit microprocessor. The TI ~99/4A uses a TMS9900,
16 ~bit microprocessor, which offers more computing power
and greater expansion and configuration flexibility than an
8~bit microprocessor. You can get higher numeric precision
and simplified memory addressing.
Programmer's aids. Programmers will enjoy the easy line
editing features. Various function keys allow you to insert or
delete characters or to erase or clear a line. There is also a
TRACE command to help in debugging.
Another feature programmers like is the built~in automatic
numbering. Just type in NUM, press ENTER, and you can start
programming. The line numbers start with 100 and automati~
cally increment by 10. Or you may specify any starting num-
ber and increment. NUM 5,2 will start with line 5 then
increment by 2.
After you have programmed and added or deleted state-
ments here and there, you'll enjoy the automatic resequencing
command, RES. This command will automatically renumber
your statements, including all statement numbers referenced
by other statements.
5
Getting Started _ _ _ _ __ "-
6
_ _ _ _ _ _ Getting Started
7
Getting Started _ _ _ _ __
Software
I've mentioned software (programs) last, although it's probably
the first extra purchase you will make for your computer. Soft-
ware is what you need to use your computer. Software is
available on command modules, cassettes, diskettes, and by
typing in programs you find in books and magazines. This
book is an example of a source of inexpensive software.
8
Write Your Own
Games
- - - - - C. Regen.
9
Getting Started ______
Randomness
Probably a central tool in computer games is the machine's
ability to choose things randomly. Most computers have the
command RND, but each computer has a slightly different
syntax (way of writing the command). On the TI-99j4A, RND
represents a random number between zero and one. Tum on
your computer, press any key to begin, and press 1 for II
BASIC. Now type in PRINT RND and press ENTER. The com-
puter will print a decimal fraction (to ten places), Usually in
game situations you won't want a fraction, so multiply that
fraction by a number. For example, multipl y RND by 10 like
this: PRINT 10'RND or PRINT RND'IO. Now you will get
ten times that decimal fraction.
You probably want just the whole number part of that
mixed decimal number. Use the fNTeger function to get the
whole number. PRINT INT(IO'RND). If you keep trying this
command, you will get numbers from zero to nine. Remember,
INT truncates the decimal portion; it does not round the num-
ber. Suppose you really wanted a random number from one
through ten. The command would be: PRINT INT(IO'RND)+I
or PRINT INT(IO'RND + I).
One more step. Assume you want a number N to be a
random number between 10 and 20, inclusive. 20 - 10 = 10.
There are 10 numbers plus 1 ("inclusive"). The command
could be N ~ INT(l1'RND)+IO. The portion INT(ll'RND)
will give you numbers from 0 to 10; then you add 10 to get
numbers from 10 to 20.
Now try this short program:
190 FOR I - I TO 10
110 PRINT INT(10*RNO)+1
120 NEXT I
10
_ _ _ _ _ _ Getting Started
11
Getting Started _ _ _ _ __
Line 110 makes sure the K value is in the right range; the key
value must be from a to 5. All other keys are ignored. Line
120 branches according to which key was pressed. The keys
corresponding to 1 and 4 were not acceptable, so they return
to the CALL KEY statement. If you want to tryout either of
these programs, add the following lines, then run and try
pressing various keys.
12
_ _ _ _ _ _ Getting Started
13
Easy Editing
- - - - - C. Regen.
Type in 130 then hold the function key (FCTN) down while
you press the down arrow (!). (It might be best to follow
through this article as you sit at your TI-99 / 4A.) You'll notice
line 130 comes up at the bottom of the screen with the cursor
at the first position. Now press FCTN and the right arrow. The
cursor will go toward the right. You may go one space at a
time, or hold the key and it will repeat. Go over to the 4 in
14. Stop right over the 4 and type 6. Press ENTER, and the
line will now be:
1 39 CALL SCREEN(16)
14 --
_ _ _ _ _ _ Getting Started
- 15
Getting Started _ _ _ _ __
Complete Renumbe r
RES is a command that stands for RESEQUENCE. You've
been programming and adding lines here and there and want
it to look nice again, all numbered by tens. Type RES and
press ENTER. As soon as the cursor reappears, your program
16
_ _ _ _ _ _ Getting Started
17
All About the
Character Set
- - - - - Michael A. Covington
Graphic H E L L 0
representation:
Numeric code: 72 69 76 76 79 32
Key H E L L 0 space
assignment: key key key key key bar
18
_ _ _ _ _ _ Getting Started
Graphic T H E R E I
representation:
Numeric code: 84 72 69 82 69 33
Key T H E R E shift Be
assignment: key key key key key 1 keys
19
Getting Started _ _ _ _ __
the user hasn 't pressed a key or hasn't yet let go of the one al·
ready looked at. The variable CODE contains the numeric
code associated with the key being pressed, if any. (The first
parameter of CALL KEY, the number 5, simply indicates that
we want the usual BASIC set of codes; specifying other num·
bers there instructs the computer to use other sets of key
assignments for various special purposes.)
The ASC and CHR$ functions allow you to convert back
and forth between numeric codes and character strings. If A$
is a character string, ASqA$) is the numeric code of its first
character; thus ASC("E") is 69. Conversely, if N is a number,
CHR$(N) is a one·character string of which N is the numeric
code; thus CHR$(69) is E. If we want the program above to
print the characters themselves rather than their codes, we can
convert the codes into characters by changing line 40 to:
40 PRINT CHR$(CODE)
The CALL CHAR subroutine allows you to alter graphic
representations using a hexadecimal code that the manual de·
scribes in detail. For instance, if you want to change the dollar
sign ($) into a British pound sign (£), just execute this
statement:
CALL CHAR(36."001C22207C20207E")
That will do it, at least as long as the program is running: The
key assignment and numeric code will be the same, but the
dollar sign will look like a pound sign. (It will revert to its
original appearance when your program stops executing.)
What's Not in the Manual
Those are the preliminaries; now we get to the really interest·
ing part (the part that isn't in the manual. at least not en·
tirely). Internally, the computer can use any number from 0 to
255 as a character code; any such code can be an element in a
character string and can be referred to by CALL YCHAR,
CALL HCHAR, and CHR$. (In fact, CALL YCHAR, CALL
HCHAR, and CHR$ will actually take numbers up to 32767;
multiples of 256 are subtracted as necessary to get a number
in the 0 to 255 range.) But not all the codes have key assign·
ments or graphic representations. The breakdown (by numeric
codes is as follows:
20
-- _ _ _ _ _ _ Getting Started
21
Getting Started _ _ _ _ __
23
Getting Started _ _ _ __
74 J 97 a
75 K 98 b
76 L 99 c
77 M 100 d
78 N 101 e
79 0 102 r
80 p 103 g
81 Q 104 h
82 R 105
83 5 106 j
84 T 107 k
85 U 108 1
86 V 109 m
87 W 110 n
88 X 111 0
89 Y 112 P
90 Z 113 q
91 [ 114
92 \ (back slash) 115 ,e
93 [ 116 t
94 117 u
95 _ (underline) 118 v
96 119 w
120 x
121 y
122 z
123 ,{
12. ,
125 )
126
2'
- - -_ _ Getting Started
25
i
~
2
TI BASIC One..
Liners
- - - - - - Michael A. Covington
29
The Basic8 _ _ _ _ __
30
_ _ _ _ _ _ The Basics
Remember that the OEF statement for ASN must precede the
DEF statement for ACS (you can 't refer to a function until
you've defined it).
7. Rounding to a particular number of decimal places. Where
n stands for the number of decimal places you want, use the
definition:
DEF ROU(X)=INT«(10 A N)'X)+0.5)/(10 A N)
31
The Basics _ _ _ _ __
That is, we subtract the integer part and the minutes; what's
left gets multiplied by 60 twice.
The sexagesimal output functions can be tested by means
of a program such as the following:
1~ DEF MNT(X ):I NT(60t(X - INT<X»)
20 DEF SCO(X):b0t(b0t(X-INT(X) )-MNT(X»
3~ FOR H =0 TO 2 STEP 0.01
40 PRINT
50 PRINT H.~HOUR S"
b~ PRINT INT(H),MNT(H) ,SCO( H)
70 NEXT H
From this we learn, for example, that 0.01 of an hour is 36
seconds, and that 0.5 of an hour is 30 minutes. (If your com-
puter uses binary, rather than BCD or Radix-IOO, internal
representations of numbers, you may get odd errors due to
rounding or lack of it. The solution would be to round the
number of hours to some reasonably small number of decimal
places before invoking the conversions, and perhaps to insert
some rounding in the definitions of MNT and SCD
themselves.)
InCidentally, for sexagesimal input, you don't need any
special functions, only a bit of multiplication. For instance, the
statements:
32
- _ _ _ _ _ The Basics
33
CALL KEY Hints
- - - - - Roger Lathrop
34
_ _ _ _ _ _ The Basics
You are now switching back and forth between key units three
and five. Key unit five is the mode the computer is in nor-
mally. You can use this to ask a question, such as YES or NO,
and have it come back as uppercase to simplify verification, no
matter how it is entered. You may then switch back to key
unit five to enter information such as names, where both upper-
and lowercase letters may be desired. Note that control keys
are inactive in key unit three, and that numeric and punctua -
tion keys work normally with the SHIFT key.
If you need to switch back and forth often in a program
you may wish to make the CALL KEY statements a separate
subroutine. You can use dummy CALL KEYs, as we did in
lines 30 and 55, or you can use an active CALL KEY using the
key unit you wish. Any following INPUT statements will react
accordingly. Once you have the keyboard mapped the way
you wish, any following CALL KEYs may use a key unit of
zero. Key unit zero will not change the keyboard mapping.
Take the time to learn this simple programming trick. It's
easy to learn, will help make your programs easier to run, and
in many cases can make them simpler to write and debug.
35
All Sorts of BASIC
Sorts
- - - - - C. Regena
Shell Sort
The Shell Sort is considerably faster than the Bubble Sort. In
general, for a random order of 50 numbers, the shell sort is
about two or three times as fast as the Bubble Sort. The Shell
Sort speeds up execution because the number of comparisons
that need to be made is reduced.
In an array of N numbers, it first determines B so that
2B< N<2B +l and then the variable B is initialized to 28+1, The
loop varies the counter I from 1 to N - B. First, it checks if
A(I)<A(J + B). If so, it increments I and continues with the
comparisons. If not, it exchanges A(I) and A(I + B) and changes
the subscript.
When I reaches the value of N, it reduces B by a factor of
two and starts the loop again. When B = 0 the sort is com-
plete. I've used a couple of extra variables in the example for
darity.
Sort C
The third kind of sort routine offered here is also faster than
the Bubble Sort if the numbers are quite mixed up. The pro-
gram goes through all the numbers and places the minimum
value in the first spot of the array. The loop keeps finding the
minimum of the numbers remaining and replaces it in order.
Sort D
This sort is similar to the previous one, except that with each
pass through the numbers, both the minimum and the maxi-
mum numbers are found and placed at the appropriate end
spots.
The way these sorts are listed, the given numbers will be
arranged in ascending order. To change to descending order,
simply exchange the less than or greater than signs in the sort
comparisons.
If you are alphabetizing, the variable terms will be string
variables, such as A$(l).
You may have several items which need to be associated
as they are sorted. For example, suppose you have names and
scores to be arranged by score. The names and scores are first
arranged as N$(I), 5(1); N$(2), 5(2); etc. In the interchange
you would need to sort the 5 values, and then switch both
terms, like this:
37
The Basics ______
55=5(1)
NNS=NS(I)
S(IJ::S(J+1)
NS (J)=NS C1+1)
S(I+1>=SS
Nt: CI +1 ) =NNS
38
______• The Basics
2 •• e"'I
27. D:C +e
28. IF A(C) {= ACDITHEN 3 ••
2 •• AA:A(C)
3 •• A(C)=A(O)
31. A(D):::AA
32. CzC - B
33. IF C>. THEN 27.
3 •• NEXT I
35. GOTO 23.
5 •• FOR t '" 1 TO 5.
5 ' . PRINT A (1) ;
52. NEXT I
53. END
39
The Basics ______•
13 5 RANDOHIZE
140 A ( I) = INT(RND*100+1)
15121 PR INT ACI ) :
16 0 NEXT I
17 0 PRINT :
2QlB 5:z 1
2 1B HN ::: A( S)
220 IMIN:::S
230 H X= HN
24B IMAX=5
250 FOR 1 =5 TO N
260 I F ACI) (= MX THEN 299
27B MX:::A( I)
28 0 IMA X=I
29 0 IF ACI»MN THEN 320
30 0 MN - ACI )
3 1B IMIN = I
320 NEXT I
330 IF IMIN () N THEN 350
3 4121 JMIN:::IMAX
35 0 AA =AC N )
360 ACN)=ACIMAX)
37 0 A( IMAX )=AA
380 N"" N- I
390 AA = AC S)
40121 A(S)=ACIHIN)
410 A(IMIN)=AA
420 5 - 5 +1
4 30 IF N ) S THEN 2 10
500 FOR 1 = 1 TO 50
5 10 PR INT A<I);
520 NEXT I
530 END
40
Searching
Algorithms
- - - - - Doug Hapeman
42
_ _ _ _ _ _ The Basics
43
The Basics _ _ _ _ __
45
The Basics _ _ _ _ __
Searching Algorithms
100 RE M tt SEARCHING ALGORITH MStt
120 DIM B$( 1 00)
130 N= 1 00
14 0 RE M t t READ AND DISPLAY DATA t t
150 CALL CLEAR
160 FOR 1 =1 TO N
170 READ A$
180 B$(I)=A$
190 PRINT B$(]),
2{11{11 NEXT I
210 FOR T=1 TO 4 00
220 NEXT T
230 RE M ttPRI NT MAIN ME NU"
240 CALL CLEAR
250 PRIN T " " SEARCHING ALGORITHMS t ' " :
: "PRESS{3 SPACES}FOR" : : " 1 LI N
EAR SEARCH ":
260 PRINT" 2 = ALPHA/LINEAR SEARCH": :"
3 BINARY SEARCH": :" 4 FINISH
SESSION":
270 CALL KEY(0,KEY,S)
280 IF KEY ( 49 THE N 270
290 IF KEY ) 52 THEN 270
300 IF KEY=S2 THEN 750 ELSE 700
310 RE M t tLINEAR SEARCH"
320 FOR 1=1 TO N
330 PR IN T I;
340 IF C$=B$(I)THEN 660
350 NEXT I
360 GOTO 640
370 REM t ' ALPHABETICAL LINEAR SEARCH"
380 FOR 1=1 TO N
390 PR IN T I;
4 00 IF C$=B$(I)THEN 660
41 0 IF C$ ( B$(I) T HEN 640
420 NEXT I
430 GOTO 640
46
_ _ _ _ _ _ The Basics
76'5 STOP
770 DATA ACKER,AINSLIE,ALLEN,ANDERSON,ARHSTR
DNG,BANCROFT,BAULD,BEATON,BEATTIE,BLACK,
BOWER,BROOKS,BROWN
780 DATA BURKE,CHANG,CHRISTIAN~CHU,COCHRANE,
CODNER,COLLIN5,COHEAU,COOK,COOPER,COX,DA
RROW,DAVIS,DAY
790 DATA OELONG.DICKIE,DOGGETT~DOUGLAS,EBBET
T ,E LLIS,EMBREE,EULOTH,FIELD,FIFIELD,FDY,
GAMMON,GREENE,HAPEMAN
B00 DATA HARPELL,HARTLIN,HILL,HUBLEY,HUSKINS
,JAMES,JAMIESON,JDHNSON,JONES,KENDALL,KE
TCHAM,KILLAWEE,KILLDRAN
47
The Basics ______
48
Transferring
Variables in TI
Extended BASIC
- - - - - - Patrick Parrish
49
The Basics _ _ _ _ __
51
The Basics ______
and the computer will display the number of variables you are
allowed to transfer.
As mentioned, pattern-identifiers must be stored as hexa -
decimal code. Our best approach here is to represent each
character of E$ by its ASCII value before converting it to
hexadecimal.
Lines 1000 to 1020 contain routines for doing this. In line
1010, each character of E$ is converted to its ASCII equiva-
lent. These ASCII values are, in turn, converted to a hexa-
decimal string expression, M1$, in line 1020.
Once M1$ reaches a length of 16 characters (or the end of
E$ is reached), it is assigned as a pattern-identifier (line 1025).
At this point, if MI$ is less than 16 characters long, TI Ex-
tended BASIC automatically fills the remaining characters in
the pattern-identifier with zeros.
Recovering Variable Data
Variable data stored with Program 1 can be recovered with
Program 2. Both programs serve as examples.
Again, you would place the main portion of your program
in lines 100-798. Be sure to DIMension 0$0 and DO in line
100 for the number of variables you stored with Program 1.
Lines 800 to 980 contain routines for recalling each vari-
able. In line 800, each pattern-identifier used to store data is
assigned as A$ using CHARPAT. In line 910, if the end of
variable data is detected as signified by "FFFF" (sequential
CHR$(255)'s), a flag variable FL is set to I.
Line 920 looks for the delimiter "FF" (CHR$(255» follow-
ing each variable 0$. If a delimiter is seen, the length of the
prior 0$0 is calculated as DO.
Two characters of A$ are set equal to M$ in line 930. The
two-digit hexadecimal number contained in M$ is sub-
sequently converted to a decimal value in line 940. These
decimal values are then converted to CHR$s in line 960 and
stored as F$.
In line 1000, F$ is divided into D$()'s using lengths DO.
As before, D$() represents the string form of each variable.
Finally, as a demonstration, our original variables are
PRINTed in line 1030. Of course, this may not be necessary in
your program.
52
______• The Basics
93121 E$=E$~CHR$(255)
999 REM CONVERT E$ TO ASC'S AND THEN TO HEX
- CO NCATENATE EVERY 16 AS MI$ OR END OF
E.
1 f2If2If2I J = 127
:: M1 $="" :: FOR K= 1 TO LEN (E<f;)
l1Z110 D=ASCCSEG<f;CE'$.K,I»
11212121 MH = lNTCD / 1 6) :: ML=D-M H*t6 :: M'$=SEG<f;CHE
X$.MH+l,l)~<SEG$(HEX"',ML+l,I):: Ml'$=M
1$ &M$
112124 REM STORE HEX STR ING MIS AS CHAR PATTER
N-IDE NTIFIER
53
The Basics ______•
54
computer VisualsRichard D. Jones and Howard Alvir
space-scroll up
T- input additional words during display
1-9-calls appropriate screen
O-calls title screen
All other keys advance the screen a line at a time.
Color is added by the CALL COLOR command. As a re-
sult any character in character set 2 is displayed as color.
Thirty-two characters will display a colored :ine.
Experiment with numerous screen variations (e.g., color
combinations, larger letters, and speech to introduce major
pOints). We have even experimented with using the speech
synthesizer to open the presentation. Adding commands in
Extended BASIC can improve graphics but it adds complexity
to the equipment.
Generating visuals by computer opens exciting possibil-
ities for the future. Certainly improvements in video display
and microcomputers will expand the application of computer
visuals. In the meantime, you can enter a new arena of pro-
fessional computer use and discard your image as a hobbyist.
Computer Visuals
100 REM ***t*t****t****t****
110 REM * CO MPUTER VISUALS *
1 20 REM ********************
130 REM
140 REM
150 REM
160 REM
170 CA LL CLEAR
180 PRINT TAB<41 ;"PRE SS ANY KEY TO BEGIN"
190 CALL KEY(0,K,S)
200 IF S:0 THEN 190
210 CALL CLEAR
220 CALL COLOR(2,5,S)
230 CALL SCREE N(1 2)
240 RESTORE 1050
250 REM FULL SCREE N ROUTINE
260 CALL CLEAR
270 READ LINES
280 IF LINE$="END" THEN 500
290 IF LINES="." THEN 970
300 IF LINE$:"~" THEN 510
310 L=LEN<LINE$)
320 M=L/2
330 I=15 - M
56
- -_ _ _ _ The Basics
57
The Basics ______
1080 DATA
10 9111
DATA **.;i)
11013 REM SCREE N 1
1110 DATA ADVANTAGE S
11 20 DATA ----------------------------
11 313DATA EASY TO EDIT,INEXPE NSIVE.ORGA NIZED
,EFFICIENT,COLORFUL.PORTABLE , ATTENTION
GATHERING
11413 DATA
1150DATA**,;i)
11 60 REM SCREEN 2
11713 DATA EQUIPMENT NEEDED, -----------------
----------- .TI 99 4A,CASSETTE RECORDER,
TELEVI S ION OR MONITOR. -------------- - --
59
Using a Printer
- - - - - C. Regeno
60
_ _ _ _ _ _ The Basics
61
The Basics _ _ _ _ __
160 CWSE #2
Closes device 2.
170 END
The print list fo ll owing th e colon in a PRI NT # statement
follows the same rules as regular printing to the screen. Since
the length of lines may be longer on the printer (the screen
has 28 columns in a print line), you may use the TAB function
to arrange your printing:
100 OPEN #1 ,"RS232.BA ~ 600"
110 PRINT #HAB(2W'MONTHlY PAYMENTS"
You may use a variable in the TAB fun ction:
200 PRINT #l,TAB(T + A);MONTH$;X
You may also use colons to print blank lin es:
220 PRINT #1 ,,,
If you have adjusted your printer properly for vertical
tabs, you may go to the top of the next page by using:
300 PRINT #l ,CHRSm)
'-
62
3
Mail~!!~te~nist
This program call be used for developing small mailing lists,
for famifies or for orgallizations. There are tell options,
including printing a single label or all entire alphabetized
mailing list.
Ten Options
Once the computer "environment" is established, you are
taken to the Main Index. Here you will discover ten options:
1 View Names List
2 Search for a Name
3 Add Names
4 Change Names
5 Delete Names
6 Alphabetize List
7 Save Data File
8 Load Data File
9 Print Labels/ List
10 Finish Session
Of course, to create a mailing list you would first choose
option 3 (Add Names). The other options will enable you to
update, maintain, and utilize an existing file. The program will
guide you step-by-step through the procedure for each option.
There are many helpful features, such as the Search, Change,
and Delete. You can also enter names and addresses in any
order, and then, by choosing the Alphabetize option, have the
computer sort them for you.
The Data File
The program is written to both save and load data files for
either cassette or disk storage. When you choose either the
Save or Load option, you will be given any further step-by-
step instructions.
Print Options
The program offers you two print options-one for mailing
labels, and the other for the mailing list.
The Print Labels option will print the first name, followed
by the last name, and then the address on lines two and three.
For example:
John Doe
1234 Street Address
City Province Postal Code
The Print Mailing List option will prin t the last name first,
fo llowed by the first name and children's names, with the ad -
dress on line two, and the phone number on line three. For
example:
66
- - - -_ _ Applications
67
Applications _ _ _ _ __
Mailing List
5 REH t.COMPUTER ENVIRONMENTtt
7 DIM LN$(45),NA$(45).CH$(45),AD$(45),CP$(45
) , PCS(45),TPS(45)
9 CALL CLEAR
11 PRINT" .(3 SPACES } 99/4A MAILING LIST
( 3 SPACES}.":
13 INPUT "(4 SPACES}PRES5 ENTER TO BEGIN":XS
15 CALL CLEAR
1 7 PRINT "(5 SPACES}WHAT ]5 THE NAME OF":"
(4 5PACES}VOUR PRINTING DEVICE ? "::M (EX
AMPLE: RS2 32 . BA=4800)":
19 INPUT PS
21 Gs = "(7 SPACES}PLEASE WAIT._. ( 7 SPACES}WHI
LE THE PRINTER IS WORKING"
2 3 REM •• MAIL LIST MENU**
25 CALL CLEAR
2 7 PRINT "(8 SPACES}MAIN INDEX u :
2 9 PRINT "PRE S S( 3 SPACES}TO": :
3 1 PRINT" VIEW NAMES LIST":" 2 =
SEARCH FOR A NAME":" 3 = ADD NAMES":M
4 CHANGE NAME S "
33 PRINT" 5 DELETE NAMES":" 6 = ALP
HABETIZE LIST":-' 7 "" SAVE DATA FILE":"
8 ~ LOAD DATA FILE"
35 PRINT" 9 = PRINT LABELS/LIST":" 10 ""
FINISH SESSION":
37 INPUT P
3 9 IF P } 10 THEN 3 7
4 1 I F P < 1 THEN 37
4 3 CALL CLEAR
4 5 ON P GOSUB 51, 77 ,11 3 ,185, 2 89,335,42 7 ,445,
47 5 ,525
4 7 GOTO 2 5
49 REM {3 SPACES } t*VIEW NAMES LIST*t
5 1 T= 0
53 FOR 1 = 1 TO N
55 T= T+l
5 7 PRINT NASCI) . LNSCI):CHSCI):ADSCI):CPSII):
PCS(I):"(P) - ";TPSCI);
59 IF T < 2 THEN 6 9
61 PRINT" tPRESS ENTER TO CONTINUEt";" *""R
"",ENTER FOR HAIN INDEX*"
6 3 INPUT X$
65 IF Xs="R" THEN 7 3
6 7 T= 0
68
- -_ _ _ _ Applications
69 NEXT I
7 1 INPUT "(7 SPACES}*END OF FILEa{9 SPACES)'
PRESS ENTER TO CONTINUE'·:X~
73 RETURN
75 REM( l SPACES} •• SEARCH NAMES ••
77 INPUT "LAST NAME? "!Y$
79 FOR 1= 1 TO N
al IF LN$ ( I) (> Y$ THEN 11213
83 PR INT :" IS THE PERSON:": :" "; NAs (
I ) : " ";LN$(I):
85 INPUT (YI N )? ": XS
87 IF X$"'''N'' THEN 10 3
89 PR J NT: : NAS (I) ,LN$ (I ) : eHS (I) : ADS (I) : CP
S(I):PC$(I):"CP l - ";TP$(I):
91 INPUT " {3 SPACES}OO YOU WI S H TO PRINT
{b SPACES}A MAILING LABEL ? (Y / N)":Zs
93 IF ZS <> "V" THEN 97
95 GO SUB 495
97 IN P UT "SEARCH MORE NAME S? (Y/ N ) ":X'I
99 IF XS="Y" THEN 77
101 GOTO 11219
1£13 N EX T I
1121 5 PRINT : ;" THE ";YS:" YOU ARE SEARCH
I NG FOR ":" IS NOT IN THIS FILE.":
Ifl17 GOTO 97
109 RETURN
111 REH {3 SPACES}"ADD NAMES._ (S S PACES )
11 3 A=N+l
115 FOR I : A TO 45
117 CALL CLEAR
119 PRINT; ; "ENTER DATA; ";".";1;" (HA
X:4S)"; ;
121 PRINT n .LAST NAHE: n
123 INPUT LN~(I)
125 PRINT;" .FIRST NAMECS):"
127 INPUT NA~(I)
129 PRINT:" .CHILDREN:":"(3 SPACES}NOTE--D
o NOT USE COMMAS~"
1 3 1 INPUT CHS(I)
1 33 PRINT:" .STREET ADDRESS:"
1 3 5 INPUT AD~(I)
1 37 PRINT :" .CITY/PROVINCE:":"{3 SPACES}NO
TE -- DO NOT USE COMMAS~ ~
1 3 9 INPUT CPS(I)
141 PRINT:" apOSTAL CODE:"
143 INPUT PCS(I )
145 PRINT;" aPHONE:"
14 7 INPUT TP~(I)
149 V=I
69
Applications _ _ _ _ __
187 IN P UT CS
lS9 CALL CLEAR
191 FOR C::l TO N+l
193 IF LNS(C) "" CS THEN 195 ELSE 239
1 95 PR I NT "IS THE PER SON :": " "; NAS (C) : " ";
REET ADDRESS"
1
NAM E (S) " : " - 3
LA S T NAME":" 2
CHILDRE N ":" 4
FIRST
ST
205 R::C
207 RS _ " *ENTER THE NEW DATA;"
2 09 PRINT 5 - C ITY / PROVINCE":" 6 ~ P
OS TAL CODE":" 7 "" PHONE":" B "" NO
CHANGE" :
211 INP UT P
2 1 3 CALL CLEAR
2 15 I F P < l THEN 211
217 IF P >8 THEN 2 11
2 19 I F P ES THEN 229
22 1 ON P GOSUe 2 45 ,25 1, 257,2 63, 26 9, 275 , 28 1
223 PRINT: ;"MORE CHANGES FOR: " :" ";NA$(R) ~
: " ";LNS(R):
70
- _____• Applications
283
•INPUT TPS(R)
285 RETURN
287 REM{3 SPACES}"DELETE NAMESl .
289 INPUT "LAST NAME? H: X$
291 FOR 1=1 TO N
293 I F LN$(I) <>X $ THEN 325
295 PRINT: :~IS THE PERSON: " :H ";NA$(I) :
H;LN$(I):
297 INPUT" (Y/N)?" : Y$
299 IF Y$<> " Y· THEN 325
301 A- I
303 FOR O=A TO N- l
395 LNS(D)=LNS(O+ l )
307 NA$(D)=NA$(D+l)
309 CH$(D)=CH$(D+l)
311 AD$(D)=AD$(D+l)
313 CP$(D)=CP$(D+l)
71
Applications _ _ _ _ __
315 PC$(D)=PC$(D+l)
317 TP$(D ):TP$(D+l)
3 1"1 NEXT D
321 N=N - l
323 GO TO 327
325 NE XT I
327 INPUT ~MORE DELETIONS? (Y/N)";X$
329 IF XS="Y" THEN 289
33 1 RETURN
333 REM ttALPHABETI ZE LISTtt{3 SPACES}
335 PRINT " (7 SPACES}PLEASE WAIT • •. ": :" T
HE LIST IS BEING ARRANGED":
337 8=1
339 B=2t9
341 IF 9 < =N THEN 339
343 B=INT IB/2)
345 IF B=0 THEN 369
347 FOR Y=1 TO N-B
3 48 X=V
3 49 I=X+B
351 IF LNS(X)=LNS(I)THEN 363
353 IF LNS(X) < LNSII)THEN 3 65
355 GOSUB 381
357 X=X - B
359 IF X>0 THEN 349
361 GOTO 365
363 GOSUB 373
365 NEXT V
367 GOTO 343
369 RETURN
371 REM t.ORDER FIRST NAMES"{3 SPACES}
373 IF NAS(X) < NAS(I)THEN 377
375 GOSUB 381
377 RETURN
37"1 REM •• CHANG E ORDERt'
38 1 N$ =L NS( X)
383 LNSIX)=LN$(I)
385 LNS(I)=NS
387 NS = NAS (X)
389 NAS(X) = NASCI )
3"11 NAS (I) =N$
393 NS=CHS(X)
395 CH$(X)=C HS (I)
397 CHSII) "" N$
399 N$ =ADS(X)
401 AD$(X)=ADSCI)
4fi.'1 3 ADS(I)::NS
405 N$=CPS( X)
40 7 CPS(X)=CPS(I)
72
_ _ _ _ _ _ Applications
469 INPUT L~
471 RETURN
473 RE M ** SUB TO PR INT LABELS/LIST'_
475 PRINT " PRESS{ 3 SPACES}TO PRINT" : : " 1
(5 SPACES } MAILING LABELS": :" 2
{ S SPACES}MAILI NG LIST":
477 INPUT P
479 IF P ( l THEN 47 7
48 1 IF P >2 THEN 47 7
483 PRINT: :6$=
73
Applications _ _ _ _ __
533 STOP
74
Statistics For
Nonstatisticians
- - - - - - A. Burke Luitich
TI Translation by Patrick Parrish
75
Applications _ _ _ _ __
divide by 5 (the total cuts for each) you will find that both
methods give the sa me meorl (average) length of 1.018 feet.
Just finding an average length doesn 't tell us much. What
we need to know is how widespread the values are likely to
be, and which method gave us the most lengths that were
nearer our standard of one foot. In statistical terms, we need
to calculate the range and the standard deviatioll.
We find the range by subtracting the shortest length from
the longest, for each cutting method. For the handsaw the
range is .48 feet (1.28-0.80), and for the table saw the range
is .11 feet (1.07-0.96). Immediately, we can see that the table
saw cut more consistently, because the range, or variation, is
smaller.
We can use the standard deviation and the mean length
to predict how often a given length is likely to occur. You
don't have to worry about how to calculate a standard de-
viation: The program does this for you. If you type in the
above lengths for the handsaw, the program will return a
standard deviation of 0.217 feet. The standard deviation for
the table saw is 0.047 feet.
Degree of Accur acy
If we made a large number of cuts, then measured and
graphed the lengths, the graph would form a bell curve, or
normal distribution. By combining the standard deviation and
the mean length, we get a range of lengths that includes 68.3
percent of all lengths (again, you don't have to know the the-
ory; just use the number). To illustrate, first take the mean
length, 1.018 feet, and subtract from it the standard deviation
for the handsaw, 0.217 feet, to get 0.801 feet. Then add the
standard deviation to the mean length to get 1.235 feet. This
means that 68.3 percent of our lengths fall in the range be-
tween 0.801 and 1.235 feet.
By adding and subtracting the standard deviation (0.047
feet) with the mean length of the table saw cuts (1.018 feet),
we find that 68.3 percent (roughly two-thirds) of these lengths
fa ll in the range from 0.971 to 1.065 feet.
If you want a wider sample, you must increase the num-
ber of standard deviations. To include 95.4 percent of all
lengths, use two standard deviations. For the handsaw, we
now have 0.434 feet, two standard deviations. Combining it
with the mean length, we get a range of 0.584 to 1.452 feet.
76
_ _ _ _ _ _ Applications
minus , plus
$41 $51 $61
(mean)
77
Applications ______•
78
_ _ _ _ _ _ Applications
-- 4 8.
4 ••
RE M DA T A E NTRY
CA LL CLEAR
509 PR INT
SUI INPUT N
TAB(3): " ENTER SA MPLE S IZE " :
79
Applications _ _ _ _ __
81
Applications ______
1740 FL=0
1750 IF K< ) 78 THEN 1780
1760 FL=l
1770 GOTO 1980
1780 IF K=81 THEN 770
1790 REM ERROR CORRECTION SUER
1800 PRINT "REMEMBER INCORRECT SA MPLE ~":
1810 PRINT TAB<lU ;" (Y/N) ?" :
82
_ _ _ _ _ _ Applications
83
TIcalc
- - - - - Raymond J. Herold
84
_ _ _ _ _ _ Applications
Starting a Business
We are starting a small manufacturing business and want to
estimate our net profit or loss for the first four months. We are
anticipating sales of $2,700 the first month and a 10 percent
growth rate for each succeeding month. Space is being leased
for $800 a month, and there are two employees making a total
of $1,200 a month. Cost for materials is based on sales and is
expected to be 30 percent, while utilities are expected to run at
roughly 5 percent of sales.
When the program begins, it displays the window with a
HOME position of AA. That is, it is displaying rows A through
J and columns A, B, and C. The COMMAND -> prompt is
displayed, and the program is awaiting your reply. Since the
first thing we want to do is enter spreadsheet data, reply IN-
SERT. This places the cursor (actually two sprites at line 860)
at the top-left slot in the window, in this case AA. The prompt
85
Applications _ _ _ __
87
~
~ Figure 2. Example Spreadsheet
A 8 c o , p G H
~;;.
A JANUA RY FEBRUA.RY MARCH AP RIL ·TOTAL· 1.10
'" SALES
•::-.
o
8 .., o
~
o
"'" .., .., SUMROW8E Cf ~OF
"NT
, SALA RY
"" SUM ROWB E CF~Ef
"00
"'" ''''
.."'"
P MATERIAL CooSI ceo III CooSI CE' SI SUMRDW8E CF"'FF
G UTILITY CR'q eeoq eooq eEoq SUMROWBE CF'IIoGf
•
)
_ _ _ _ _ _ Applications
Procedures
Now you can use the CALC command to calculate the result
of the working copy. The calculation will take anywhere from
a few seconds to a few minutes, depending on the size of the
working copy and the number of calculations. When the
calculation is complete, the program will automatically go into
MODE2 and set the HOME row and column to AA. You can
then view the results by moving the window, using the
HOME command. Figure 3 shows the results from the sample.
If you want to see the calcu lation that gave a particular result,
you can type MODEl to see the original working copy as
shown in Figure 2. Typing MODE2 will return you to the " re-
sult copy." This is particularly useful in finding errors.
Figure 3. Printout of Example Worksheet
Results
JANUARY FEBRUARY MARCH APRIL -TOTAL- '" SALES
SALES 2700 2970 3267 3593.7 12530.7
RENT 800 800 SOO 800 3200 25.53
SALARY 1200 1200 1200 1200 4800 38.3
MATERIAL 810 891 980.1 1078.11 3759.21 30
UTILITY 135 148.5 163.35 179.68 626.53 4.99
TOT EXP 2945 3039.5 3143.45 3257.79 12385.74 98.84
NET +j - - 245 - 69.5 123.55 335.91 144.96 1.15
89
Applications ______
90
_ _ _ _ _ _ Applications
CALC Calculates the results for the values and calcu lations in
the working copy; invokes MODE2 at completion.
LOAD Load a spreadsheet from tape.
SAVE Save a spreadsheet to tape.
PRINT Print spreadsheet.
lNSERT Subcommands
Subcommands Action
.,5) Move cursor left .
-(D) Move cursor right.
HE) Move cursor up.
I (X) Move cursor down.
L Indicates a label is to be placed in the current cursor
position.
N Indicates a numeric value is to be placed in the CUT ·
rent cursor position.
C Indicates a calculation is to be placed in the current
cursor position.
Q Quit; return to command mode.
91
Applications _ _ _ _ __
Examples
AB·CG
AL - AI
EF + AH
BC/CA
AB +CB·BC
AB + CB + CA Processed left to right
CB/AB -CH
SUMROWCF
SUMCOLAH
Tlcalc:
1121121 DIM A$(26.14),B$(26,14)
110 CALL CHAR(96."FFFFFFFFFFFFFFFF"):: CALL
COLOR(9,13,1)
129 ROW=l : : COL=1 : : RLIM=19 :: CL IM =3
130 Rcs="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
149 CALL CHAR(104,"FFFFEI2IE0E0E0FFFF"):: CALL
CHAR(10S."FFFF07070707FFFF"):: CALL CO L
OR ( 10. 7, 1 )
150 CALL CLEAR :: CALL SCREEN(9)
160 DISPLAY AT(S, 7): "E A S Y CAL C" :: DIS
PLAY AT(9.9): "ELECTRONIC" :: DISPLAY AT(
11,9):"SPREADSHEET"
170 FOR DELAY=1 TO 2000 :: NEXT DELAY
180 CALL CLEAR:: CALL SCREENCS)
199 CALL HCHAR(4, 3 .96. 29)
290 CALL VCHAR(S,4.96, 19)
210 CALL VCHAR(S, 1 3,96, 19)
220 CALL VCHAR(S,22,96, 19)
230 GOSUe 349 : : MODE=1
2 40 DISPLAY AT(I,l):"COMMAND: --- ) " :: ACeEP
T AT(1,lS)SIZE(6)BEEP:COMM$
25121 IF SEG S(COMMS ,l,4)="HO ME" THEN 41121
26121 IF SEGS(CO MMS.l, 6)="I NSERT" THEN 72121
279 IF SEGS(COM MS.l. S) - "MODEl" THEN GOSUS 52
9 :: GOTO 249
280 IF SEGS(COMMS, l,S)="MODE2" THEN GOSUe 62
" :: GOTO 240
92
_ _ _ _ _ _ Applications
93
Applications _ _ _ _ __
97121 NEXT Z
98121 WS = RPTSe" ".W)~W$
99121 DISPLAY ATeX,Y):W$;
Ieee AS(R.C) = "N:"~WS
11211121 RM = MAxeRM,R):: CM=MAxeCM,C)
11212121 GOTO 74121
1121 3 121 DISPLAY ATel,I):"CALCULATION: ---) " ::
ACCEPT AT(I,19)SIZE(B)BEEP:C$
11214121 IF SEGSeCS,I,6):"SUHROW" THEN 119121
11215121 IF SEGS(CS, l.b)="SUMCOL" THEN 119121
11216121 AAS=SEGS(C$,3,1)
11217121 IF AAS="+" OR AAS=" - " OR AA$="." OR AA$
- "/" OR AAS - "X" THEN 11219121
94
_______ Applications
.3.
DELAY:::} TO 1200 :: NEXT DELAV .. GOTO 1
95
Applications _ _ _ _ __
96
_ _ _ _ _ _ Applications
97
Applications _______
98
Financial Interests
- - - - - Doug Hapeman
99
Applications _ _ _ _ __
100
_ _ _ _ _ _ Applications
Savincs Analysis
The Savings analysis lets you examine a combination of two
investment procedures: investments (the fu ture value of a
101
Applications ______
102
______ Applications
Annuities
5 = Am t>lo(1+ lrN) - l
Amt·FR
5 ~ 1- (I /1+FRrN)
FR = Loa n amortization factor
R = Annual interest rate
5 = The monthly payment
Amt = Amou nt to be borrowed
N = Length of loans in months
Mortgage Payments
FR ~ «1+ R/200)( 1/6)) - 1
Amt·FR
5 - 1- (1/«1 +FRrN))
FR = Mortgage amortization factor
R = Annual interest rate
5 = The monthly payment
Amt = A mount to be borrowed
N = Length of mortgage in months
Program Outline
l00- JOO Initialization and title screen
310-340 Main menu
350-360 Finish session
370-430 Get loan and mortgage information
440-510 Calculate and display monthly payment
520-560 Month-by-month analysis
570- 630 Analysis calcu lations
640- 680 Print amortization schedule
690-790 Display calculations
800-900 Get savings in formation
910- 940 Savings analysis
950- 970 Analysis calculations
980- 1020 Display calculations
103
Applications _ _ _ _ __
Financ:ial Interest
100 REM " FINANCIA L INTERE S TS *'
110 REM EXTENDED BASI C RE QUIRED
120 DIM A(S )
130 CAL L CLEA R
140 REM ttt***' I NITIA L I ZATION L TITLE SCREEN
*'*""
104
_ _ _ _ _ _ Applications
- 170 C=96
REEN( 1 2)
"9. ::
••
X= 1 2
X=8
::
y-", 10
Y= 14
..
GOSUB
GOSUB 190
180 ::
C = 12
GOTO 1
GOSUB 28 121
2'5121 C=256 :: V=13 o . H=27 .. RR=23 o . CC= 4 ..
J=I .. C$="tPRESS AN Y KEY TO BEGIN." ..
GOSUB 28 9
26121 CALL DEL S PRITE(#1 1
279 CALL KEY (121, K, SI :: IF S = 0 THEN 270 EL SE 3.
2.
280 CALL MOTION(#l ,V, H):: IF J=0 THEN 313121
2913 FOR 1= 1 TO LE NC CSI : : X=ASC(SEGS(CS, I , 1)
.. CALL HCHARCRR ,C C+I .X) :: NEXT t
300 CALL COINCCtH,R,C,12,1):: IF 1=9 THEN 39
9 :: CALL HOTIONC.I,e,0):: C ALL LOCATE C.
I ,R , C) :: RETURN
3 1121 REH . t • • t •• MAIN ME NU ••• t •• t
31'5 CALL VCHARCI,3,32.672):: RETURN
32121 GOSUB 3 15 : : DISPLAY ATC5,5)BEEP:"FINANC
tAL INTERESTS": :"PRESS{3 SPACES}FOR
"; : " I = LOAN ANALYSIS": :" 2
MORTGAGE ANAL-YSI S "
339 DISPLAY ATC16 , 3) :" 3 SAV ING S ANALY S I S
": : " 4 = FINISH SESSION " : : CALL KEY
( 0, K, S ):: IF K<49 OR K >52 THEN 33i!1
3 40 ON K- 4B GO TO 380,430,910,360
359 REM • • • t.t*FINISH SESSION* •• tt ••
36i!1 DISP LAY ATC14,7)ERASE ALL: "HAVE A NI CE D
AY!" STOP
37121 RE M t t t t . t t GET LOAN IN FOR MATION*ttt*t*
105
Applications ______•
..
E RATE OF INTEREST: U : : 8$(2)="LENGTH OF
LOAN IN MONTH S :" ;: GOTO 410
390 REM tt,tlttSE T MORTGAGE IN FOR MATIONttttt
106
_ _ _ _ _ _ Applications
t.*_.
640 REM •• "t*.PRINT AMORTIZATION SCHEDULE'*
lOB
A Mini Data Base
-. Management
System
Raymond J. Herold
109
Applications ______
110
_ _ _ _ _ Applications
111
Applications ______
in the record and its associated mask. You simply enter the
data you want for each new record. After the record is added
a display will show how many records are currently in the file
and the maximum number allowed for that file. At this point
you can add another record or return to the main program
menu. Figure 3 shows a record that has just been added.
Figure 3. Add New Record
ADD NEW RECORD
NAME .. COMPUTE! .. . ...... .
ADDR .. P.O. BOX 5406 .... .
CITYST GREENSBO RO NC ....... .
ZIP.. 27403
DATE .. 10/04/84
AMOUNT 00024.00
FOR ... SUBSCRIPTION ......... .
112
_ _ _ _ _ _ Applications
113
Applications _ _ _ _ __
the field. You first provide the program with the number of
fields you want printed, and the name of the fields. You may
summarize a field if desired, and you may selectively print
based on the value of a search argument. The report to be
printed may be given a title. The program checks for a maxi-
mum 80 columns of print data, but allows you to print more if
desired.
If you request this option but don't have a printer you
will get a syntax error. Also, you may have to adjust the
OPEN statement in line 8006 to accommodate your particular
printer.
Table J. Program Subdivisions
Line
Number
10-30 Introduction banner
100-190 Menu display
looo-l4UO Define new DBMS file
2000-2060 Read data from tape
3000-3200 Add records to file
4000-4440 Display/update records
5000-5220 Sort routine
6000-6030 Write data to tape
7000-7430 Search, summarize and display
8000-8200 Produce printed report
114
_ _ _ _ _ _ Applications
Program l, MINI-DBMS
1 REM TI MINI - DBM S
2 REM
1121 CALL CLEAR : : CAL L SCREEN (9 )
2121 DISPLAY AT (3 . 1):RPT$("*~.28 1 :: DISPLAY AT
(4,1):"." :: DISPLAY ATC4,28):"."
22 DI S PLAY AT(5 , l ) : " t {4 SPACES}M I N I - 0 B
M S{5 SPACES}."
24 DISPLAY ATCb,I):"." :: DISPLAY AT(6,2B) : "
*" ::
DISPLAY AT(7,1):RPT$C"." . 2B)
3121 FOR X=i TO 21211210 :: NEXT X
4121 DIM At;(81 ,B)
1121121 CALL CLEAR : : CA LL SCREE NCS):: DISPLAY A
T(2,112I):"** MENU t t "
l1i21 0 I SPLAY AT (6, 1 ) : "1 - DEF I NE NEW DBMS REC
ORDS" :: DISPLAY AT(S, 1 ) :"2 - LOAD RE COR
OS FROM T APE"
120 DISPLAY AT(10. 1):" 3 - ENTER NEW RECORDS"
: : DISPLAY AT(12 , 1):"4 - DISPLAY/UPDATE
RECORDS"
130 DISPLAY AT(14 , I } :"5 - S ORT BY SPECIFIED
FIELD"
140 DISPLA Y ATiI6,1):"6 - SAVE DATA ON TAPE"
150 DISPLAY ATc2 3 . 3) :"ENTER SELECTION ---> " :
: ACCEPT AT(23.2 3 )VALIDATEC"123456")BEEP
:CHOICE
170 ON CHOICE GOTO 10B0,2000, 3 ~00.4000,5000,
6000
190 GOTO 100
4 00 FOR X=l TO 2000 :: NEXT X
41 0 GOTO 1 00
1090 CALL CLEAR :: DISPLAY AT i3 ,1):"OEFINE R
ECORO FORMAT FOR" :: DISPLAY AT{4, 1): "N
EW DBMS. YOU MAY DEFINE UP"
1005 DISPLAY AT(S, l ) : "TO B FIELDS IN THE REC
OF<D. "
115
Applications ______
116
- - - - - _ Applications
117
Applications ______
118
______• Applications
119
Applications ______
51211215 FLD=I2I
512119 FOR L=1 TO FIELDS
512112 IF FLDS=FNMSILlTHEN FLD =L :: L-99
512113 NEXT L
512115 IF FLD = 12I THEN DISPLAY AT114, 1,:"NO SUCH
FIELD NAME." :: DISPLAV AT(lS,ll :'''R~
TO RETRY - 'M' FOR MENU" ELSE GOTO 51214121
51212121 CAL L KEYI3,KEY.STATUS): : IF S TATUS=9 TH
E N 51212121
51213121 IF KEY=82 THEN 50121121 ELSE 1~t21
512149 DISPLAY ATI2IZ1,I):"SORTING . . . "
595121 Y-I :: HX =@ :: FOR Z= I TO FIELDS :: AS !
121,1)=" ____ " :: NEXT 1
51215555=121 :: DISPLAY ATe2121, I): "SORTING . . . ";R
ECS-Y
596121 FOR X=Y TO RECS
512165 IF ASIX,FLD' ( AS(I2I,FLDlTHE N GOSUS 511210
512179 NE XT X
5975 IF 55=1 THEN GOSUS 5290
51218121 Y=Y +l :: FOR 1=1 TO FIELDS: : AS (121, Z)=A
SIY, Z) : ; NE XT Z
512185 IF Y( RECS THEN 512155
512199 GO TO 19121
5 1121 9 FOR 1=1 TO FIELDS •. ASe0,Z)=AseX,Z)::
NEXT Z :: HX =X : : 55 = 1 .. RETURN
52121121 FOR Z=1 T O FIELDS
521121 HS-AS(Y,Z):: AS(Y ,Z)= AS(HX,Z):: AS( HX,Z
)= HS
522121 NE XT Z :: RETURN
6el2l1Z1 CALL CLEAR
6121 1121 OPEN #l ;"CS l",OU TPUT, INTERNAL,FIXED 19 2
61212121 PRI NT #l:NAHES;FIELD S; RECS;NUMREC
61213121 FOR L = l TO FIELDS :: PRINT #l: F NMS(L l ;T
YPS( L );LNI L' ; MA SKS(L):: NEXT L
612135 F OR X=I TO RECS
69 4121 PRINT #1:AS( X,J );AS(X,2);AS(X,3);AS ( X,4
) ; At (X, 5' ; AS ( X, 6) ; AS (X, 7) ; AS (X, B)
6e4S NEXT X
61215121 CLO SE # J :: GO TO 1121 121
Program 2. MINI-HEPT
1 REM TI MINI -R EPT
2 REM
Ie CALL CLEAR :: CALL SCREEN(9)
2121 DISPLAY AT(3,1):RPT$("t",2B):: DISPLAY AT
(4,1):"." : ; DISPLAY AT(4,ZS):"."
22 DISPLAY AT(S.l ) : " ' { 4 S PA CES}M I N I - R E
P T {S S PACES } '"
110
______• Applications
121
Applications _ _ _ _ __
4100 HOLD=RECS
4110 FOR RECS=1 TO HOLD
4115 IF RECS >HOLD THEN 4150
4120 Bosue 4 3 00
4130 CALL KEY(3,KEV,STATUS)
4132 IF STATUS=0 THEN 4130
4134 IF KEV=13 THEN 4150
4136 IF KEV=77 THEN RECS=999 :: GOTO 4150
4138 BOTO 4130
4150 NEXT RECS
4155 RECS=HOLD
4160 BOT a 100
4200 CALL CLEAR :: DISPLAV ATC2,l):"" DISPL
AV BV FIELD VALUE •• "
4205 DISPLAV AT(5,1):NENTER THE NAME OF THE
DATA" :: DISPLAY ATlb,1): "FIELD TO BE S
EARCHED AND THE"
4210 DISPLAY ATI7,1):NSEARCH ARGUMENT (VALUE
) ."
4220 DISPLAV AT(12,1):"FIELD TO BE SEARCHED
.. ACCEPT AT(12,22)SIZE(-b):FLD
4221
•FLD=0
4222 FOR L = l TO FIELDS
4224 IF FLD$=FNM$(L)THEN FLD=L :: L =99
4226 NEXT L
4228 IF FLD=0 THEN DISPLAV ATCI4,l):"NO SUCH
FIELD NAME." :: DISPLAV AT(t5,l):'''R'
TO RETRV - "M" FOR MENU" ELSE GOTO 4250
4230 CALL KEVC3,KEY,STATUS)
4232 IF STATUS=0 THEN 4230
4234 IF KEY=82 THEN 4200 ELSE 100
4250 DISPLAV AT(14.1):-ENTER SEARCH VALUE
{S SPACES}"
425 2 ACCEPT AT(15,l):ARG$
4260 HOLD=RE CS
4262 FOR RECS:l TO HOLD
4 26 4 IF ARB$=SEG$(A$(RECS,FLD). l,LEN(ARG$»T
HEN GOSUB 4 300 ELSE 4 290
4270 CALL KEV(3,KEY,STATUS)
4272 IF STATUS=0 THEN 4270
4274 IF KEY=13 THEN 4290
4276 IF KEY=77 THEN RECS:999 BOTO 4290
4280 GOTO 42 70
4290 NEXT RECS
4292 RECS=HOLD
4294 GOlD 100
4300 CALL CLEAR :: DISPLAY AT(2,6):N" OISPL
AV RECORDS •• "
122
_ _ _ _ _ _ Applications
123
Applications _ _ _ _ __
124
- _____• Applications
8076 NEXT L
8078 PR INT 1t 2 :L$
8079 IF p(0) <~ el THEN GOSIJB 82Q!0
125
Applications ______
8~8S NEXT Q
8982 IF P(0) = 0 THEN 8S9S
8S84 PRINT "2:" " :: PRINT #2:" .. :: PRINT ..
2:"TOTAL FOR ";FNM~(P{S » ;" ";TOT
8999 CLOSE .. 2 :: GOTO 199
81~0 CALL CLEAR : : DI S PLAY AT (3 ,1):"SEARCH 8
Y FIELD NAME ? YIN ." :: ACCEPT AT( 3 , 2 7)
VALIDATE ( "YN")BEEP:OPT~ .. IF OPT~ = ·N"
THEN RETURN
8119 DISPLAY ATCS,l):"SEARCH FIELD NAME . . . .
.. " :: ACCEPT AT('5,19) S IZE (- b)BEEP:FLD~
8120 FLD=~ :: FOR L = l TO FIELD S
81 2 '5 IF FLD~ = FNM~(L ) THEN FLD = L
81 3 0 NEXT L
8140 IF FLD = ~ THEN 8110
81'50 DI S PLAY AT(b.l':"ENTER S EARCH VALUE" ..
ACCEPT AT (7 .1):ARG~
8l b S RETURN
8200 RE CS = Q . . S UM - PC0 ' :: S= 1 •. GOSUB 7 100
:: 5= 0 :: RETURN
126
TI Word Processor
- - - - - James D. Bake<
127
Applications _ _ _ _ __
128
- _ _ _ _ _ Applications
Next Line. This option displays the next text line. If se-
lected, program execution is transferred to line 900. This rou-
tine first sets the number-of-records-forward counter to one.
The loop in lines 940-980 follows the next record pointer
through the file until the requested number of records forward
has been read.
A check is made to insure that a READ past the end of
file does not occur. If this is attempted, the program displays
the last line of text, a warning message, and returns to the
main change menu. Upon completion of the loop, program
control is returned to the main change menu.
It should be noted that the loop is not necessary in order
to display the next line. However, it is also used to advance
any number of records by using the third option discussed
below.
Last Line. This option displays the previous line of text.
The routine starting at line 1000 provides for stepping back-
ward through the text file. This routine is the same as the
prior routine except that the previous record pointer is used in
order to proceed to the previous record.
129
Applications ______
130
_ _ _ _ _ _ Applications
The 14 lines are then " looped " through, allowing any
changes desired. Note that the maximum length of any subtext
line is limited to 26 characters and that if the special end
character is accidentally deleted, the program will restore this
character. The length of the new text line is recalculated since
this length could now exceed the maximum string length
permitted by the computer.
After the text has been changed, the new text length is
checked to see if it exceeds 225 characters. If the length is less
than 226 characters, the text line is reconstructed and control
is transferred to line 2050.
If the length of the new text line exceeds 225 characters, a
menu offering two choices is displayed: either update as modi-
fied and create a new record on disk or reupdate the line. If
the reupdate choice is selected, control is transferred to the
beginning of the change routine with no changes made.
If the choice is made to update and create a new record,
lines 1900-1940 establish two new text strings consisting of
the first seven and last seven subtext lines respectively. The
current record being changed is then replaced on disk by the
first new text string created. The second new text string is then
added to the file using the Add After routine. Note that the re-
turn switch has been set in line 1950 causing control to return
to this routine after the add is completed.
The first of the new records is retrieved, and control is re-
turned to display this as the current record and to display the
main change menu.
If the change process did not cause a new record to be
added, lines 2050- 2130 display the changed text and offer
three choices: perform more updates, update the record as dis-
played, or exit with no updating.
Delete. The routine for this option, which allows you to
delete a line of text, begins at line 2180. You will be asked for
confirmation before the delete is executed. If the choice is
made not to delete the line, control is passed back to line 780
where the current line is redispJayed and the main menu
choices are available.
If you choose to delete the line, the previous and next
record pointers from this " to be deleted" record are saved. The
previous record is then read and updated with the next record
pointer from the deleted record. The record after the deleted
record is then read and updated with the previous record
131
Applications ______
pointer from the deleted record. Note that the record just
deleted is only deleted from the standpoint that the record
pointers no longer allow access to the record.
A check is then made to insure that this delete has nct
caused all text to be deleted. If this is the case, the program
displays a message to that effect and terminates. Otherwise, if
a record still exists before the deleted record, control is passed
to line 1000 and the previous record is displayed. If the record
prior to the deleted record is the header record, control is
passed to line 900, and the record follOWing the deleted record
is displayed.
Print File
The print routine begins at line 2400. Lines 2480-2540 estab-
lish the default values for top margin (TM), bottom margin
(BM), left margin (LM), page length (PL), lines per page (LPP),
and maximum line length (MAXWID). Print control infor-
mation is then requested, including mode of print (draft or fi-
nal), spacing (single or double), and optional page numbering.
The input file is then " restored" to restart from the first
record on file, and the printer output file is opened. Note that
the parallel port is used in this program. If you are using the
serial port for your printer, the OPEN statement in line 2730
will require appropriate changes.
The first record on file is read to retrieve the next record
pointer for the first text record . The main print " loop" begins
at line 2820 where the next text record is read using the next
record pointer from the previous record.
If draft printing was requested, control is passed to that
routine (line 2880). [f the current record is a forced new page
request UN I), the subroutine at line 3900 causes a page eject
and the top margin to be printed. Control is then returned to
the main print loop.
Line 2850 passes control to the ending routine if this is
the last text record. Otherwise, control is passed to the print fi-
nal routine (line 2980).
Print Draft. This routine (lines 2870-2930) simply prints
the lines of text in sequence exactly as entered. This includes
printing any special print commands, but does not effect these
commands. This is useful if you want to see what was entered
for verification purposes and do not want pagination, etc. This
print mode is also faster than final printing as the special print
commands are not executed.
132
- -_ _ _ _ Applications
TI Word Processor
100 RE M WORD PROCE SS I NG
130 DIM Al$(14)
140 GOsue 425121
150 CALL CLEAR
I bl2l DISPLAY AT(10.7 l : "WORD PROCESS I NG"
170 DISPLAY AT(ll.3l:" - ENTRY / UPDATE PROGRAM
133
Applications _ _ _ _ __
134
_ _ _ _ _ _ Applications
135
Applications _ _ _ _ __
1100 REM
111121 REM FOWARD/BACK X LINES
112121 REM
113121 DISPLAY AT(22,16):"NBR LINES"
114121 ACCEPT AT(22,26)BEEP:NBRLNS
1150 IF C:3 THEN NBRFWD=NBRLNS :: GOTO 94121
1160 NBRBACK:NBRLNS
117121 GOTO 1040
118121 REM
119121 REM ADD BEFORE/AFTER
1200 REM
121121 CALL CLEAR
1220 IF C:6 THEN PRINT "ADD NEW LINE AFTER:"
ELSE PRINT "ADD NEW LINE BEFORE:"
1230 PRINT
124121 PRINT At;
1250 PRINT
1269 PRINT "ENTER NEW LINE" . . . .
127121 LINPUT ANt;
1289 HREC:RECNO
1290 HLST=LSTREC
1309 HNXT=NXTREC
1310 INPUT *I,REC EOFREC:A$,LSTREC,ADDREC
132121 HADD:ADDREC
1330 PRINT .1,REC EOFREC:A$,LSTREC,ADDREC+l
134121 IF C:6 OR RETSW:l THEN 1450
1350 REM
1360 REM ADD BEFORE
1370 REM
1380 PRINT .I,REC HADD:AN$.HLST,HREC
1390 INPUT *1,REC HlST:A$,LSTREC.NXTREC
1490 PRINT .I,REC HlST:AS.LSTREC,HADD
1410 INPUT .I,REC HREC:AS,LSTREC,NXTREC
1420 PRINT .I,REC HREC:AS,HADD,NXTREC
1430 NXTREC : HADD
1440 IF RETSW = l THEN 2010 ELSE GOTO 700
1450 REM
1460 REM ADD AFTER
1470 REM
1480 PRINT .I,REC HADD:ANt;,HREC,HNXT
1490 INPUT .I,REC HREC:AS,lSTREC.NXTREC
1500 PRINT .I,REC HREC:AS , LSTREC,HADD
1510 INPUT .1,REC HNXT:A$.LSTREC,NXTREC
1520 PRINT .1,REC HNXT:A$,HADD,NXTREC
1530 GOTO 1430
1540 REM
155121 REM CHANGE
156121 REM
1570 CALL CLEAR
1580 LENAl=INT(LENCA$) / 14)+1
136
- _ _ _ _ _• Applications
137
Applications _ _ _ _ __
138
_ _ _ _ _ _• Applications
2 480 TM=b
2490 BMEb
2500 LH -= t
251" PL:abb
2520 LC=0
253£1 LPP"PL - BM
2540 HAXWID -bB
2550 DI SPLAY ATCle,7): WORD PROCESSING"
2560 DISPLAY ATIlt,b): - PRINT PROGRAM - "
2570 DI SPLAY AT(tS,I): F ILENAME - DSKl.";F.
25B0 DISPLAY ATI20.l): PRINT HODE - OfF"
2590 DISPLAY AT(22,1) : SPACING - SID"
2600 DISPLAY AT(24,l): PAGE NUHBER (YIN)"
26 10 ACCEPT AT(20,20)S ZEll)BEEP VALIDATE("O
Fd-f"):Mt;
2620 IF LENIN$):" THEN 2610
2630 IF H$ z "d" THEN H$ ="O"
26 40 I F MS - "f" THEN Ht; . "F"
26S0 ACCEPT AT(22,20'SIZE(I)BEEP VALIDATEC"S
Dsd") : SPG$
2660 IF LEN<5PG$)=0 THEN 2650
2670 IF SPG$ z '·s · THEN SPGS_"S ·
2680 IF SPG$:"d " THEN SPG$="O"
269 0 ACCEPT AT(24,20)SIZE( I IBEEP VALIDATE( " Y
Nyn"):PGNO$
270 0 IF LENCPGNO$)=0 THEN 2690
2710 IF PGNO$:~yh THEN PGNO$=uY h
2720 RESTORE .1
2730 OPEN .2;"PIO"
27 40 GOSUB 3800
2750 REM
2760 REM READ INITIAL RECORD
277 0 REM
2780 INPUT *l:A$,LSTREC,NXTREC
2790 REM
2800 REM READ INPUT FI LE
2810 REM
2820 INPUT 11,REC NXTREC:A$,L STREC. NXTREC
2830 IF M$ - "D" THEN 2850
2840 IF SEG$(A $,l,3l . " / N/ " OR SEG$(A$, 1, 3)- "
In/ " THEN PRINT *2 :; LC=LC+l :: GOSUB
3900 :: GO TO 2800
2 859 TF SEG1;(A1; , I, 3 ) _ " / E / " OR SEG$(A$ , l, 3 )z"
l e I " THEN 2940
28 60 IF HS - "F~ T HEN 2980
2 87 0 REM
2 880 REM PRINT DRAFT
2 89121 REM
291210 PRI NT .2:AS
2 91121 LC = LC+l
139
Applications _ _ _ _ __
337il REM
33 80 FOR I = INIT TO LEN ( A. )
33 90 PC=PC+l
3 499 A2$ = 5EG.(A$ ~ I, 1 )
3 41 0 IF PC=l+LM AND A2$-" • THEN PC - LM .. GO
TO 3 44"
3 4 20 IF A2 $ = " " THEN 3 4b0
3 4 30 PRINT * 2:A2$;
3 448 NEXT I
3 4 50 GOTO 2800
3 4 60 INIT = 1 :: P RINT *2 :: LC=LC+l :: PRINT
*2:RPT$C" " . LM):
3 470 IF SPG$ - "D" THEN PRINT * 2 :: LC =LC+I
PRINT *2:RPT$ C" ".LM);
3 480 IF LC >= LPP THEN GOSUS 3900
3 49 13 PC = LM
35 00 IF INIT = LEN CA$)THEN 2 800
35 10 IF S EG.,(A$, INIT.l) = " .. THEN INIT oa INIT+l
:: GOTO 3590
3520 A$ =S EGS(AS.INIT.LEN ( AS) - INIT+l)
35311' GOTO 3 050
35 40 REM
355 0 REM CENTERING ROUTINE
356 9 REM
357 0 I F PC ) LM THEN PR I NT .2 .• LC = LC+ 1 :: PR
INT M2:RPTs(" ",LM):
3580 IF PC ) LM AND SPGS="D" THEN PRINT .2 ..
LC a LC+l :: PRINT MZ :R PTS(M ",LMlJ
3590 PC=L M
3 600 IF LC >= LPP THEN GOSUB 391210
3 610 C:""E N=LE N(A$) -3
3 6 20 S P=INT«MAXWID-LM - CLEN)/2>
3630 PRINT *2:RPT$(" -.SP+LM);
36 4121 PRINT * 2 :SEG$(A~.4,LEN(A~»
3650 LC=LC+l :: PRINT *2: RPT~ (" ". LM);
366121 IF S PG~ = "D " THEN PRINT *2 :: LC = LC+l
PRINT * 2 : RPT~(" ·'.LM);
3 6 7 121 IF LC >=LPP THEN GOSUS 391210
3680 GOTO 2800
3690 REM
3700 REM PRINT BLANK LINE
37 10 REM
3720 IF PC=LM THEN 3759
373121 PRINT .2 : : LC~LC+l
37 49 IF SPG$="D" THEN PRINT *2 :: LC=LC+l
3750 PRINT 12 :: LC""LC+t :: PR1NT .2:RPT~("
.. , LM) ;
376121 IF SPG~="D" THEN PRINT *2 . . LC - LC+l ::
PRINT tl2:RPT$(" ".LM):
141
App lications ______
142
_ _ _ _ _ _ Applications
143
!
~
u
,
~
/
I
~
, I
~
, I
~
4
Trap
Larry Michalewicz
Each player must avoid the walls while trying to force his
opponent to collide witlt him or a wall. It gets tricky. A two-
player game, joyst icks required.
147
Recreation _______
Trap
100 P::0
110 Q::0
120 CALL CHARC1 20,"-'
13 0 CALL CHAR( 1 35,"")
140 CALL CHAR(13b,"")
150 CALL CLEAR
160 CALL 5CREEN(3)
170 CALL COLORC I 3 , l , 7)
180 CALL COLOR(14, 1,5)
190 REM 5ET UP PLAYING FIELD
200 PRINT ·PLAYER .1 "; P ,"PLAYER . 2 ";0
2 10 FOR 0::1 TO 22
220 PRINT
230 NEXT 0
2 40 CALL COLORCI2 ,2,2)
25 0 CALL HCHAR( 2,2,120,3 0 )
26 0 CALL HCHAR( 2 4, 2 , 1 20 , 3 0)
27 0 CALL VCHAR(2,2, 120,23)
280 CA LL VCHAR( 2.3 1,1 20,23)
2 90 C l :: 1 2
3 00 C2:: 1 2
3HI 01::4
320 D2:28
33 0 Rl =0
3 40 5 1: 1
35 0 R2= 0
36 0 52 :: - 1
37 0 11=0
3 80 1 2=0
390 REM MAIN L OOPCMOVEMENT)
400 CALL JOY5TC1,Bl,Al)
410 IF AB5(Al) - AB 5CB l )= 0 THEN 440
420 R l=Al / 4
430 5 1 = 81 / 4
440 Cl =C I -R l
450 01=01+51
460 CALL JOY 5T C2 ,82, A2)
470 IF AB 5( A2)- AB S CB2) =0 THEN 500
480 R2=A2/4
490 52:: B2 / 4
500 C2=C2-R2
5 10 02=02+52
52 0 CALL GCHARCCI,Dl,G)
530 IF 6= 32 THEN 550
5 40 11=1
550 CALL VCHAR (C l,DI,1 3 5)
560 CALL 50 UNO ( l ,262,0)
570 CA LL GCHARCC2,02,G)
148
_______ Recreation
149
Duck Leader
- - - - - Douglas E. Smith and Douglas W. Smith
150
_ _ _ _ _ _ Recreation
3. INSTRUCTIONS? (YIN)
Enter Y to read the instructions before the game begins.
This screen briefly describes the game and the functions of the
appropriate keys used for the game. It also shows the graphic
characters used for the reeds, hunters, and the marsh exit.
4. FIRST NAME OF THE LEAD DUCK?
Type in your first name or the name of your favorite
duck, and press ENTER. The game will then begin.
If you entered Y for instructions, they will appear first. Hit
the 1 key to begin play.
At first the outline of the marsh appears, and then the
positions of the reeds and hunters are indicated. You have 15
seconds to study the locations before the reeds and hunters
become invisible.
Successful Maneuvers
The duck on the left side of the marsh represents your squad·
ron. Move the duck by using the arrow keys (E, 5, D, and X).
You do not have to press ENTER or use the FeTN key.
If you hit the sides of the marsh or the invisible reed,
your ducks will bounce back to the starting position, but you
do not lose an y ducks.
Meeting a hunter will result in gunfire and the loss o f a
duck, with the survivors returning to the start again.
The positions of the reeds and hun ters do not change un-
til you reach the exit to the next marsh .
Your goal is to maneuver your squadron to the right side
of the marsh and out the exit to the next marsh. Once you
have passed through the five marshes to safety, the program
will congratula te you, show you the remaining ducks, and
prin t your score.
The highest possible score is 6000 and can be achieved
only at level 2 with the difficulty rating 10. Nobody has
achieved this score to date.
The marsh border color changes to red if the sq uadron is
depleted to ten or fewer ducks. Losing all the squadron will
put you in Duck Soup, and give you a zero score.
After the score is printed, the program w ill ask PLAY
AGAIN? (YIN). Enter Y to play again at the last selected level
and difficulty. Enter N to choose a different level and
difficulty.
151
Recreation ______
152
_ _ _ _ _ _ Recreation
153
Recreation ______
Duck Leader
120 RANDOMIZE
13.0GOSUB 1720
140 CALL COLOR(1 3 ,2,1)
150 CALL COLOR(14,S,16)
160 CALL COLOR (11, 1 3, 1 )
170 CALL COLOR(12,10,1)
180 CALL CLEAR
190 CALL SCREEN(12)
2.00FOR X=1 TO 19
210 PRINT" DUCK LEADER DUCK LEADER"
220 NEXT X
230 PRINT
240 GOSUB 330
250 GO SUB 142121
26.0INPUT "LEVELs?(IEHELP/2=N0 HELP)":LEVEL
270 INPUT nDIFFICULTV~?(1-10)":DIF
280 IF (DIF < 1)+(DIF > 10)THEN 270
290 J NPUT "I NSTRUCT IONS ? (V IN) " : I NS$
30 "INPUT "FIRST NAME OF LEAD DUCK ?- :NAMES
3 10IF INSS:"Y· THEN 4 20
32" GO TO 520
330 FOR Y=12 TO 14 STEP 2
3 40FOR X=l TO 32
35 0CALL HCHAR(Y,X,1 29)
3 60CALL SOUND(25,-5,lS)
370 CALL HCHAR(V,X, 128)
38 0CALL HCHAR(Y ,X ,32)
390 NEXT X
400 NEXT V
410 RETURN
420 CALL CLEAR
430 PRINT NAMES:
440 PRINT ·YOU ARE THE LEADER OF A-: :-SQUAD
RON OF THIRT Y DUCKS." : : "PADDLE THROUGH
FIVE MARSHES- :
450 PRINT -TO SAFETY!! -: : "USE ARROW KEYS TO
Move": :"H -KEY FOR HELP(QNLV FIVE)": :"
N-K EY=NEW HAR S H(-S DUCKS)":
154
_ _ _ _ _ _ Recreation
156
_ _ _ _ _ _ Recreation
157
Freeway 2000
- - - - - John B. Dorff
Dare you cross the freeway of the future? You better ',ave all
your wits together, for this ;s olle grueling highway. It will
take all the cUl/ning and speed you call muster to cross this
fen-lane roadway. Requires Extended BASIC and joysticks. A
Speech Synthesizer is optional.
If you've been trying to write games in BASIC, you have prob-
ably found out that it can be difficult to design fast-action
games. Creating a game with many moving objects on the
screen, moving in all directions, is next to impossible; BASIC
is just too slow. Still, with TI's great graphic and sprite
capabilities, there are ways to create fun and exciting games
once you learn to work with BASIC's limitations. Extended
BASIC is the best way to create such a game.
"Freeway 2000" is just such a game. It takes advantage of
TI's graphics and sprites. To save program space, there are no
REM statements or instructions for the game included in the
program. For the same reason, and to increase speed, almost
all the lines in the program are multistatement lines. Save the
program after you have typed it in and before you run it.
Some speech has been added to enhance the game, so if
you have a speech synthesizer, connect it before you play.
There is nothing like a game that compl iments you when
you've made a good run, or chides you when you goof.
158
_ _ _ _ _ _ Recreation
Fr eeway 2000
1~ RANDOMIZE : : CALL SPGET(MSET" . S$) : : CALL
SPGET(HGOOD".G$) :: CALL SPGET(" MOVE". M$ ) :
: CAll SPGET("WEll". W$)
159
Recreation _______
160
- -_____ Recreation
162
_______ Recreation
163
Recreation _______
FOR 0 = 1
TO 200 :: NEXT 0 : : IF A THEN 790
900 CALL HCHAR(22,11, 32 ,9) :: IF P=l THEN P=2
. . A= l ELSE P=l .. A= l
91. CALL HCHAR(24 ,3 , 32 ,10):: IF A THEN 320
92. IF P=l THEN P=2 : : GOTO 320 ELSE P=l
GOTO 32 0
930 DATA 96,0,26,14,5b, 130,204,0,223, 177,26,
224, 103, 85, 3, 252, 11216, U36, 1 28, 95. 44, 4 , 2 40
,35,11,2,126,16,121
164
The Chase
- - - - - Dennis M. Reddington
Watch ou t for those ghosts. If they catch your jewel coll ectors
the price can be quite costly: Once all six of your collecters are
caught, the game ends.
The object of " The Chase" is to collect jewels. The play-
fie ld for The Chase is a 7 X 11 grid. Move your jewel collec-
tors around by moving the joystick or by using the keyboard's
arrow keys (E, up; X, down; 5, left; and D, right). If you man-
age to gather all the jewels you' ll move to the next level of
play. Be careful-don't let a ghost catch your jewel collector,
for if he's caugh t all the jewels will be placed back onto the
playing grid.
Design Considerations
The Chase is of interest to a TI-99j 4A programmer because it
demonstrates some ways to develop a relatively fast moving
game in BASIC that pressures the player to keep moving. Sev-
eral of the game design and programming considerations used
in The Chase can be used in other BASIC games to speed up
the action. They include:
• The use of color changes to give the appearance of fast game
action;
• Limiting the playing grid's size to a relatively small portion
of the screen so that, in a game like The Chase, captures and
escapes can take place quickly;
• Randomly generating each game to add variety to the game's
play;
• Checking first for the more common joystick movements and
thus reducing the amount of time required to react to the
player'S request to move;
• Changing character patterns on the screen to give the player
the feeling of action;
• Minimizing the time-consuming task of displaying the score
and other text;
• Coordinating the sound with joystick movement;
• Increasing the difficulty level as the game progresses to
higher levels.
165
Recreation ______
Game Scoring
Play continues until all six jewel collectors are captured. Each
time you clear the playing board, you will advance to the next
level of play. Scoring is based on the level of play: For each
jewel coll ected you'll get a number of pOints equal to ten times
the level. For example, level 1 scores 10 points for each jewel
collected, level 8 scores 80, and so on.
The Chase
1 00 CALL CLEAR
1 10 PRINT "T H E C H A 5 E"
120 PRINT
1 30 PRINT NJoystick 1 7 l/ENTER"
140 PRINT NJoystick 27 2/ENTERN
150 PRINT " Key board ? 3/ENTER"
160 PRINT
1 70 INPUT JT S W
180 PRINT
190 PRINT N============_="
200 IF JTS W=1 THEN 230
210 IF JT S W=2 THEN 230
220 IF JTS W<>3 THEN 11110 ELSE 25111
230 PRINT NALPHA LOCK Off"
2 40 GOTO 260
250 PRINT "ALPHA LOCK On"
260 PRI NT " =---------=-=="
270 PRINT
280 PRINT "Please Press ENTER"
290 PRINT " To BEGIN
300 CALL KEY(0.X,Y)
3 10 Z=Z+l
320 IF Y=0 THEN 300
330 IF 1 < 100 THEN 360
3 4 0 Z=Z-90
350 GOTO 330
360 RANDOMIZE Z
370 CALL CLEAR
380 H~ = " FF"
3 90 V~=N10101010t0J01010"
400 P~ = " 00B018t8"
410 PO~="00"
4212' Gl~="lB3C5AFFFF919191"
430 G2~=" 18 3 C5AFFFF242424"
44 0 SI~="003C5A5A5A7E3C"
450 S2$="003C7E42427E3C"
460 El$="0000001818"
4 70 E2$="000024181824"
480 E3$="0200249818240048"
166
.............. Recreation
167
Recreation ______•
168
_ _ _ _ _ _ Recreation
169
Recreation ______
170
_ _ _ _ _ _ Recreation
171
Thinking Andy VanDuyne
TI Version by Patrick Parrish
172
_ _ _ _ _ _ Recreation
173
Recreation ______
Thinking
lee GOTO 15e
lie FOR U ~ 1 TO LEN(O.)
12e CALL HCHAR(ROW.COL+U.ASC( S Ea.(o •. u . J»)
13e NEXT U
14£1 RETURN
15£1 CALL CLEAR
169 CALL SCREE N (6)
1 7£1 PRINT TA8(7);"T H J N KIN a":
18£1 G=6
1ge 81 R2
2e£l 82"'17
21e REM G- 9
22£1 RE M 81 -3
23e REM 92 =2 6
24e REM PRINT TA8(9);"H A ROE R"
25£1 PRINT :
26e FOR I ~ l TO 25£1
27£1 NEXT J
28£1 G.. ... STR.<G)
29£1 aosue 164 £1
3 e£l CALL CLEAR
31£1 CALL SCREE N ( 1 4)
32 9 aosue 203£1
33 0 00 = 1
3 4£1 CALL CLEAR
3 5£1 FOR N=1 TO G
3 6£1 CH(N)==e
37 £1 NEXT N
38£1 FOR N= I TO 9
3 9£1 C(NI - £1
4£1£1 CALL COlOR(N+5.2.2)
41£1 NEXT N
420 CO-0
4 3 £1 Gosue 221£1
44£1 FOR N- l TO G
459 RANDOMIZE
46£1 Z~INTIRNO 'G )+1
4 7£1 IF CH (Z) <> £1 THEN 46£1
48£1 CHIZI - N
490 NE XT N
see FOR 8=1 TO 91
51£1 FOR N= 1 TO 9
52£1 RANDOMIZE
530 Z=INT(RNOt9)+t
5 4£1 IF Y(Z) <> 0 THEN 53£1
55£1 YIZ)zN
56£1 NEXT N
57£1 FOR N ~ l TO 9
174
- -_____ Recreation
5S0 X= V(N)
59121 XS;SEG'S(STRS(X),l.l)
61'1'19 PS(B)=PS(B)~XS
6 18 N EXT N
628 FOR N=l TO 9
630 YIN)=0
6 49 NEXT N
659 GOsue 2210
6613 NEXT B
679 HS =P$(l)&PS(Z)
68121 IF 6 <> 9 THEN 79121
698 HS=P$(1)LPs<2)t.P$( 3 )
79121 FOR N=l TO 82 STEP 3
718 P$(INT(N/3)+I)=SEG$(Hs .N. 3>
729 NEXT N
73121 CALL SCREE N(1 5)
74121 FOR 1 =9 TO 23
750 CALL VCHAR(4. I .64.15)
769 NEXT I
779 Ct - 72
781'1J R-b
799 FOR 5=1 TO 3
889 J::l1
81121 FOR Q=Cl TO Cl+16 STEP 8
820 FOR I=R TO R+2
839 CALL HCHAR(I.J.Q,3)
849 NEXT I
85121 J - J+4
860 NEX T Q
870 R=-R+4
a8e Cl::Cl+24
890 NEXT 5
91210 KH:o:49
91121 FOR T = 12 TO 2121 STEP -4
929 CALL HCHAR(7.T,KH)
938 CALL HCHAR(IJ.T, KH+3)
949 CALL HCHAR(15 . T,KH+b)
950 KH..-K H+l
960 NEXT T
97121 0-0
980 RDW=2
998 COL;10
112180 O'li=". ( 1 - "t.G'$&;") ?"
112110 Gosue li e
10 20 ROW"'20
11213121 COL=ll!1
1040 D$ zM". '~ • :"
1050 GOSUB 110
1060 ROW=22
175
Recreation ______
176
_ _ _ _ _ _ Recreation
177
Recreation ______
178
Bowling Champ
Joseph Ganci
TI Translation by Patrick Parrish
179
Recreation ______
down all ten pins with the first ball-you don't get a second
ball, but the current ball 's score is ten plus the total of your
next two throws.
If some pins are left standing after your first ball, you get
a second ball. If you knock down all the remaining pins, it
counts as a spare, and the current ball's score is ten plus your
next throw.
If any pins remain after your second ball (no strike or
spare), the number of pins knocked down in that frame is
added to your previous score.
Rolling a spare in the tenth (last) frame gains you one ex-
tra ball; rolling a strike in the tenth frame gains two extra
balls.
Therefore, a perfect game-ten strikes during regular play
plus two strikes with the extra bowling balls-scores 300
points. Needless to say, this doesn't happen very often, either
in real bowling or in Bowling Champ.
Is It Too Hard?
You can make the game easier with just two simple changes.
Remove STEP 2 from line 1660 and delete line 1740 entirely.
Bowline Champ
I11J0 GOTO 150
110 FOR 1 =1 TO LEN(HS)
1 20 CALL HCHARCR,C+I,A SC ( SEGS( HS,I.l»)
1 30 NEXT I
140 RETURN
150 GOSUB 2 440
160 DI M NAMES( 3),SSC3),T TC 3)
1 70 G=15
lal1J H=23
1911J CALL CLEAR
200 CALL SCREEN(6)
210 PRINT TAB(S);"B 0 W LIN G": :
220 PRINT TAB(9);"C HAM P ~H: : : : : :
: : : : :
230 PR INT TAB (3) ; "HOW MANY PLAYERS (1-4) ?. H. ,
240 CALL KEY(0.A.S)
250 I F 5=0 THEN 240
260 IF (A ( 49)+(A ) 52)THEN 2 411J
270 A=A-48
280 CALL CLEAR
2911J CAL L SCREEN(13)
180
_______ Recreation
3 00 Xf;="NA ME S"
3 10 IF A<> l THEN 33 0
32 0 X$"'''NAHE''
330 PRINT "TVPE IN YOUR ";X'S;":":
3 40 FOR 1 = 0 TO A- I
356 PRINT
3 • • PRINT TAB(4);"PLAVER .";I+l;~ " .•
37 . INPUT NAME. eI)
38. NAHE$(I):SEG$ (NA HESCI) ,l ,8)
3 •• NEXT I
•••
'1.
REM DRAW GAME SC REEN
CALL CLEAR
42. CALL SCREE N ( 12)
43. H$ - "t 2 '3 " 5 6 7 8 9 10"
4'.
45.
R- l
C=l
4 •• GOSUB 110
47.
48.
4 •• GQSUS 110
5 •• FOR J = 1 TO A
SI. HS - " y y y y y y y y y ••
52. R=2tJ+l
5 3 . GOSUe 110
5 •• H$"''' xxxXXXXXXXXXXXXXXXXXXXXXXXXXXX ''
55. R- 2tJ+2
5 •• GOSUS 110
57. NEXT J
58. R-13+(A ) 2)'2
.1..2.•••
5 •• FOR J=1 TO A
639
CzI- ( (J:::2)'" (J - 4) ) t15
R'"'R - (J=3)'2
H$=NAHES(J-l)~":"
GOSUS 1 tel
640 NEXT J
650 REM INITIALIZE SCORE STATE
660 FOR J=0 TO A- I
670 SSIJ)=1
680 TTl,])"""
690 NEXT J
-- 700 REM PUT DOWN ALLEV
710
72 0
CALL COLOR(13,l,l)
FOR J = G TO H
730 CALL HCHARIJ,2,E,30)
7 40 NEXT J
759 CALL HCHAR(J4, 2,120,30)
7b0 CALL HCHAR(24, 2,120,30)
77 0 REM MAIN LOOP
780 FOR Q=1 TO 10
790 FOR RR=0 TO A- I
181
Recreation ______
182
_ _ _ _ _ _ Recreation
1 3 "" GO TO 9 2 0
1 3 10 REM FIR S T BALL
1 32 0 FOR 1 = 1 6 TO 22 S TEP 2
1330 CALL VCHAR CI, 30.1 1 2)
1340 NEXT I
1350 FO R 1 =17 TO 21 STEP 2
1360 CALL VCHA R CI, 29.1 1 2 )
1 37 0 NEXT I
1 380 CALL HCHARI18, 2B, 11 Z)
1 39 0 CALL HC HAR(20,28,11 2)
1400 C ALL HC HAR(19,2 7 , 11 2)
1410 PS=-l
14 20 Jl=0
14 30 GOT a 14610
1440 REM S E COND BALL
14 50 PS=0
1460 SOSUB 1580
14 70 T=TT(RR)
1480 S=SSCRR)
1490 T =T+J
1590 ON SS(RR)GOS UB 2200,2250,2309,23 40, 239 0
1510' TT(RR )= T
1 520' 5S(RR)=5
15 30 R=13+(A ) 2>'2-(RR ) ll'2
1540 C= 10 -« RR = 1)+(RR =3» '15
1550 HS =S TRS (T T(RR»
1560 SOSUB 110
157 0' RETURN
1 5 80 IF (Q=1),(PS=-1),(RR=0)THEN 1650'
159" C=30
160'0' FOR HH =C TO 3 S TE P - 1
1610' CALL HCHAR(15 .H H+l ,E )
1620' CALL HCHAR(1 5, HH,B)
1 630 NEX T HH
1640 CALL HCHARC15~HH+l,E)
1650 C:::3
1 660 FOR R=6 TO H 5TEP 2
16 70 CALL HCHAR(R,C ,B )
1680 CALL KEVC0,K,5T)
1 6 90 CALL HCHARCR,C,E)
1 700 I F 5 T=0 T HEN 1 730
1 710 ROW=R
17 20 R=H
1 730 NEX T R
1 7 40 6=1 5-C 8=15 )
17 50 IF 5T=0 THEN 1660
1760 R=R OW
17 70 J=0
1 780 FOR C=3 TO 25
1790 CA LL HCHARCR,C ,E)
183
Recreation ______•
1B4
_ _ _ _ _ _ Recreation
2390 T=T+J*2
2310 IF J:10 THEN 2330
2320 5=4
2330 RETURN
2340 T-T+J
-~ 2350 S=1
2369 IF Jl <> 10 THEN 2380
2370 5=5
2380 RETURN
2399 T=T+J
2400 5= 1
2410 IF J <> lt3 THEN 2430
2 420 5=2
2430 RETURN
2440 FOR 1=97 TO 107
2 4'50 READ CS
2460 CALL CHAR(I . CS)
2470 NEXT I
2480 FOR 1=112 TO 1 28 STEP 8
2490 READ CS
2'599 CALL CHAR(I.C'S)
2510 NEXT I
2'529 CALL CHAR(121."0010 101 01010100t3")
2530 CALL CHAR(138."FFBBBBD7EFD7BBBB")
2540 E=129
2550 CA LL CHAR(129,·'·)
2569 B=128
2570 RETURN
2580 DATA FFFFFBF7EFDFBFFF.FFC7BBBBBBBBBBC7,
FFEFCFEFEFEFEFC7.FFC7BBFBF7EFDF83
25913 DATA FFC7BBFBE7FBBBC7.FFF7E7D7B783F7F7.
FF83BF87FBFBBBC7
2600 DATA FFE70FBF87BBBBC7.FF8 3 FBF7EFDFDFDF.
FFC7BBBBC7BBBBC7
2610 DATA FFC7BBBBC3FBF7CF
2620 DATA lClC081C 3 E3E 3 ElC.000000FF00000000.
003C7E7E7E7E7E3C
185
Worm of Remer
- - - - - Stephen D. Fultz
TI Translation by Patrick Parrish
Nerm the worm is lost in Bemer Castle and needs your help
to get home. You must guide him through 11 rooms Qlld help
him find magic mushrooms to eat a/ollg the way. The journey
is Q nQvigator's nightmare, because you never know where
the next mushroom will grow, and if Nerm hits a wall or
gets trapped by his tail, he loses one of his lives.
"Worm of Berner" is a fast-paced arcade game in which Nerm
the Worm travels through rooms eating magic mushrooms.
Nerm is lost in Berner Castle and wants to return home. Guide
Nerm to a mushroom using the keyboard arrow keys (E, 5, D,
and X) so he can keep up his strength for the journey. After
eati ng five mushrooms in a room, Nerm can exit to the next
room. You must guide Nerm through 11 rooms before he
finds his home. You start out with four lives. If you touch
anything besides a mushroom you will lose a life.
At the top of the screen you will see th e current score,
what room Nerm is in, how many mushrooms Nerm must eat
to open the exits, and how many lives Nerm has left, includ-
ing the current life. You get 100 pOints, plus bonus points, for
every mushroom you eat. Nerm gets a bonus li fe after
completing the first two rooms and another for every third
room thereafter.
Adding More Features
You can learn a lot about programming and games by modify-
ing the action and settings in Worm of Berner. Some featu res
you might add include a routine to save the high score to disk,
adding more players, or having Nerm go to a different room _J
186
_ _ _ _ _ _ Recreation
19 GOTO 500121
2121 FOR 1:1 TO LEN(H~)
30 CALL HCHARCROW.COL+J . ASC(SEG'5 CHt, I. 11»
35 NEXT I
40 RETURN
100 CALL KEV(0.K,ST)
195 IF (K <> 68)+(OD - 2 ) THEN 11 0
106 OX = 1
197 DY=0
108 01 = 1
119 IF ( K<> 8 3 )+(OO : 1)THEN 115
111 DX"' - l
112 OV::I2I
113 01 = 2
115 IF (K <> 69)+(OD =3 'THEN 120
1160Y "- 1
11 7 OX"'0
118 01 = 4
129 IF ( K<> BB)+ ( OD = 4)THEN 140
12 5 OY = 1
1 3 '" DX = 0
13 5 01= 3
140 CALL HCHARCYA.XA. 1 3 6)
145 QO ::. DI
150 XA:XA+OX
152 YA:VA+DV
154 L - LEN<XA'5)
156 XA'5=XA$~CHR$(XA)
158 YAS = YA$~CHRS(YA)
160 CALL GCHAR(VA,XA ,Z >
162 IF 2 <>3 2 THEN 2 00
164 CALL HCHARCVA.XA,128>
lob CALL SOUNO(1,62 2 , 2 )
168 IF L < WO THEN 100
170 CALL HCHAR(ASCCYAS),ASC<XAS), 32 l
172 LL =LENeXAS) - 1
174 XAS = SEGS(XAS,2,LL>
176 VAS=SEGS(YAS . 2.LL)
189 GOTO 10121
2121121 CALL SOUNOC I 12I0, 3 11 , 2)
21211 CALL HCHAR(YA.XA. 1 2 8)
203 SOsue 660121
205 IF Z<) MU SH THEN 2 bl2l
2 10 WO = WO+15+2lLO
212 IF WO < 185 THEN 2 15
214 WQ=18'5
215 RANDOMIZE
216 XX - RNO*28+3
2 18 X=R ND119+4
22121 CALL GCHAR(X,XX.Hl)
187
Recreation ______
189
Recreation ______
1289 NEXT I
1299 NEXT T
1291 CALL SCREEN(2)
1293 GOTO 7700
1 3 09 CA LL CLEAR
1 305 PRINT uSCORE =u;TAB( 201; UROOM :u
1319 PRINT "MU S HROOMS :";TAB( 20);UL IV ES :U
1320 FOR T =1 TO 21
1330 PR INT
1 3 40 NEXT T
1350 RETURN
1400 FOR T=5 TO 21
1410 CA LL HCHAR(T,4 ,120, 2 6)
14 20 NEXT T
14 30 RETURN
4999 RE M UP THE GA ME
50g0 GOS UB 10000
5005 MUSH = 112
5010 L I =4
5 015 SC::0
5020 LO::!
5035 HI=5
5040 WO =5
5045 EX=2
5050 Ll=3
5055 GOSUB 5500
5060 CALL CLEAR
5065 CALL SC REEN( 2)
5066 F OR 1 =3 TO 8
50 67 CALL COLOR(I.16,1)
5068 NEXT 1
5070 GOS UE 1 309
512175 GOSUB 6690
59 8121 XA$=" U
50 81 YA$="U
512185 XA=17
5986 YA=18
509 1 OX=0
5093 DY=-l
5193 I F HI < 6 THEN 5 1 1217
511215 HI = 5
5107 IF HI )- l THEN 51 1 0
5109 HI ;11I
5 11 121 01 - 4
5 115 FOR 1 =2 TO 3 1 STEP 29
5 1 2111 CAL L VCHAR(3.I,120,21)
5125 NEXT I
5130 FOR 1 =3 TO 2 3 STEP 20
5135 CALL HCHA R< 1 ,3.120,28)
5 14 0 NEXT I
190
_ _ _ _ _ _ Recreation
191
Recreation ______
7858 NEXT I
7868 RETURN
7499 REM OOP!!
7'580 CALL CLEAR
7585 PRINT TAB(13);~00PS~
751£'1 FOR 1~1 TO 12
7515 PRINT
7528 NEXT I
7525 LI=LI-l
7547 FOR 1=14 TO 24
7549 CAL L SOUNO(10,I'48,2)
7551 NEXT I
7553 FOR 1 = 1 TO 39
7555 NEXT 1
7569 IF LI ( l THEN 7799
7575 eOSUB 1 399
76121121 RETURN
7699 REM THE GAME ENDS
778121 CALL CLEAR
7794 FOR 1 =3 TO 8
7795 CALL COLOR(I,16.1)
7796 NEXT I
7719 IF HS ) SC THEN 7750
7720 HS-SC
7721 FOR 1 =1 TO 5
7722 PRINT
7723 NEXT I
7725 PRINT TAB(8);NNEW HIGH SCORE"
7728 FOR T-118 TO 1768 STEP 59
7729 CALL SOUNO(2,T,2)
7730 NEXT T
7748 FOR 1=1 TO 5
77 4 3 PRINT
7745 NEXT I
7750 PRINT TAB(7);"YOUR SCORE: ";SC
7755 PRINT
7768 PRINT TAB(7);~HIGH SCORE : ";HS
7770 FOR 1 - 1 TO 3
7775 PRINT
7780 NEXT I
7785 PRINT TAB(5);"YOUR NEW RANK IS :"
7798 PRINT
7795 PRINT TAB(9) ;RANK$(LO)
7796 FOR ]=15 TO 29
7797 CA LL SOUNO(109,NNCI).2)
7798 NEXT I
7898 PRINT
7805 PRINT
7896 PRINT
7818 PRINT ~(C TO CONT INUE Q TO QUIT)N
192
______• Recreation
193
Recreation ______
194
I
'-'
, I
( I
l..J
, I
~
I
'-..-'
I
'-'
5
TI Graphics Made
Easy
---..;;~ Lyle O. Haga
Left Right
Btock Block
197
Sound and Graphics _ _ _ _ __
•• CALL HCHAR(12,B,100,4)
50 CALL HCHAR(lb,8,100,4)
6. CALL HCHAR (12.8,101,4)
8.7. 8.
CALL HCHAR(12,12,101,4)
GaTa
No matter what you do, this won't work; there will al-
ways be a gap somewhere. Remember that even though you
didn't stipulate all 64 dots in CHAR 100, you still have them
to deal with.
198
_ _ _ _ _ _ Sound and Graphics
With this, let's make our heart. First, color in all the
squares making your heart. Then, starting at the top row, add
up the nu mbers over the squares you darkened. If the total is
under ten, your pattern code will be that number, and if it is
over nine, you see the letters A-F. You do the one complete
grid and then move to the right; when you are through, move
199
Sound and Graphics _ _ _ _ __
down to the next line. You should come up with the following
results:
8 4 2 1 8 4 2 1 8 4 2 1 842 1
A - 10
B = 11
C ~ 12
D ~ 13
E ~ 14
F ~ 15
200
Animating TI
Displays Without
Sprites
- - - - - Jim Schlegel
201
Sound and Graphics _ _ _ __
Character Table
The first table, the Character Table, is a list of the 768 charac-
ters (24 rows by 32 columns) to be displayed. The numbers
stored in this table represent the characters to be displayed at
each row and column position. The letter A is represented by
the number 65, B by 66, C by 67, etc. Numbers 32-127 are
defined by the ASCII character set but can be redefined by the
BASIC program. ASCII characters 128- 159 are also available
for defining special characters. This table is accessed by four
CALL instructions:
CALL CLEAR
CALL HCHAR(row, column, character[,repetitions])
CALL VCHAR(row, column, character[,repetitions])
CALL GCHAR(row, column, character)
CALL CLEAR sets all numbers in the table to 32 (a space
character). CALL HCHAR and CALL VCHAR are used to put
numbers into the Character Table while CALL GCHAR is used
202
_ _ _ _ _ _ Sound and Graphics
to get numbers from the table. Note that the repetitions argu-
ment for the CALL HCHAR and CALL VCHAR instructions is
optional. If this argument is omitted, one character is written
to the position defined by the row and column arguments. If
this argument is used, a row or column of characters is written
to the display. The argument " repetitions" defines the length
of the row or column. For example, CALL HCHAR(l ,l ,65,lO)
will print ten letter A's horizontally starting at row one, column
one.
Pattern Table
The second table, the Pattern Table, is a list of 128 8-byte
character patterns. The first entry in the list represents the pat-
tern for character number 32, the second entry is for character
number 33, and so on. The last pattern, entry 128, represents
the pattern for character number 159. Each character is an 8 X 8
pixel, 2-color pattern where each 1-pixel represents the fore -
ground color and each O-pixel represents the background
color. This table is modified by one CALL instruction:
CALL CHAR(character, pattern)
CALL CHAR defines which pixels are to be displayed as
the foreground color and which are to be displayed as the
background color. An example of a CALL CHAR instruction is
shown in Figure 2.
Figure 2. CALL CHAR Instruction
CALL CHAR(128,"1898FF3D3C3CE404")
Binary Hexadecimal
,,--r-ipattern~=t~ 0001 1000 18
1001 1000 98
11111111 FF
0011 1101 3D
00111100 3C
00111100 3C
11100100 E4
0000 0100 04
Color Table
The color table is a list of 16 foreground and background color
combinations to be used when displaying the characters. The
charact, ~rs defined in the Pattern Table are arranged in sets of
203
Sound and Graphics ______
Creating Animation
Most computer games use animated players to liven up the ac-
tion during play. To do this, the program running the game
must change the pattern of the player to make them move.
Muncllman and TI Invaders are good examples of games using
animated players. Two or more patterns representing different
positions of the player are built using the CALL CHAR
instruction. The patterns are then alternately displayed creat-
ing animation. Also, using and changing colors can add to the
effect of animation.
By using the BASIC instructions for creating displays, sev-
eral different methods can be used to create the same display.
Some methods, however, are preferable because they are easier
to write and run faster. The faster a program can run , the bet-
ter the animated display will be.
Many games display the same type of player several times
and move each of these players simultaneously. TI Invaders is
a good example. Several rows of about ten aliens move
204
_ _ _ _ _ Sound and Graphics
about, each moving its legs and/or arms. Each row is made of
only one type of alien; all of the aliens in a row move their
arms and legs the same way. This type of animation can be
created two different ways on the 99j4A.
Both methods will use a common subroutine to animate
the players:
800 REM· N = Number of Players
810 REM· RP = Array of Row Positions of Players
820 REM· CP "'" Array of Col Positions of Players
830 REM· C = Character Number of Player Pattern
840 FOR I ~ 1 TO N
850 CALL HCHAR(RP(I),CP(I),C)
860 NEXT I
870 RETURN
The first method uses this subroutine when the player
changes their row and column positions and when the players
move their arms and/or legs:
100 REM· Define Player Patterns
110 CALL CHAR(I28,"1898FF3D3C3CE404")
120 CALL CHAR(129:'1819FFBC3C3C2720")
610 C - 128
620 GOSUB 800
205
Sound and Graphics _ _ _ _ __
206
_ _ _ _ _ _ Sound and Graphics
Defining the object pattern would make the object rea ppear.
This requires execution of only one instruction.
Third, the CALL COLOR instruction could be used to
change the Color Table. By defining both the foreground and
background colors the same, the object is no longer visible. If
the object is on a game board, the color of the board should
be used. Setting both the foreground and background colors to
transparent (1), the color defined by the CALL SCREEN
instruction would be used. One advantage of using the CALL
COWR instruction is that up to eight distinct objects could be
made to appear and disappear with one instruction, while the
CALL CHAR instruction would have to be executed once for
each distinct object. A single object composed of up to eight
character patterns could be changed with a single CALL
COLOR instruction.
Example Animated Program
The following BASIC program uses the techniques described
in this article to produce an animated game. The object of the
game is to maneuver the marble into the hole at the opposite
comer of the display. Between the marble and the hole are
two to five kids trying to catch the marble. The kids can only
be seen at the start of the game or when one is close to the
marble. The arrow keys on the keyboard are used to maneu-
ver the marble.
Marble
••• DEFI NE
I •• REM
11. REM PLAYERS
12_ REM
13. BGC=8
14_ SQUARE:::128
1'_ SQR$="0000000000000000"
1._ CALL CHAR(SQUARE,SQR$)
17_ CALL COLOR (13,1, BGC)
18_ KID=13b
19. KDl$="1898FF3D3C3CE404"
209.1KD2$="1819FFBC3C3C2720"
21. CALL CHAR(K ID.KDl$ )
22. CALL COLOR( 14, 2,BGC)
23. MAR8LE=144
,,-
24_ MR8$="003C7E7E7E7E3C00"
CALL CHAR( MAR8LE ,MR8$)
2 •• CALL COLOR(lS.1b ,8G C)
207
Sound and Graphics _ _ _ _ __
270 HOLE=lS2
280 HOL.="FFC381818181C 3 FF"
2 90CALL CHAR(HOLE,HOLS)
3 00CALL COLOR(16 . 2.1 )
310 REM •
3 20REM • DISPLAY BOARD
33 0REM *
3 40CALL CLEAR
3 50CALL SCREEN(10 )
3 60C=7
3 70L =2 0
380 FOR R= 3 TO 22
3 90CALL HCHAR(R, C , S QUARE,L )
400 NEXT R
410 REM.
420 REM. POSITION KIDS {3 S P AC E S}
430 REH •
440 DIM KR(1 0 ).KC { 10)
450 RANDOMIZE
460 KN = INT(4'RND ) + 2
470 FOR N= l TO KN
480 KR(N)=INT (2 0'RND1+ 3
490 KC(Nl = INT(20'RND ) +7
500 CALL HCHAR( KR(N ) .K C (N). V- ID )
510 NEXT N
520 REM •
530 REM * POSITION HO LE {3 S PA CE S }
51'. 0
REM •
550 HR = 4
560 HC= 8
57 0CALL HCHA R( HR .H C .H OLE}
58 0REM •
590 REM. PO S I T ION MA R BLE
600 REM •
6 19MR =2 1
62 0MC=2 5
630 CALL HCHAR ( MR.M C .MA RBLE)
6 40REM ~ {3 S PA CE S}
650 REM. WAIT F OR VEY{5 SP ACE S ]
660 REM t {3 S PA CE S }
670 CALL KEY ( I. KE Y . S TATU S)
680 IF STATUS = 0 THEN 67 0
690 CALL COLOR(14.B GC . BGC )
700 REM •
7 10REM. BEGIN GAM E
720 REM •
730 CALL CHAR {KI D.KDI. )
740 CALL KEY( I . KE Y. S TA TUS)
750 IF STATU S= 0 THEN 97 0
760 J = l
208
______ Sound and Graphics
209
Sound and Graphics ______
1270 NEXT I
1 280 GOT a 100
1290 REM *
1 3 00 REM *
PLAYER LOSE S
1 3 1121 REM *
1320 CALL CO LOR ( 15~ 7, 8GC)
1 33 0 CALL HCHAR CMR,M C ,MARBLE)
1 3 4121 FOR J = -5 TO -7 S TEP - I
1 3 5121 CAL L SOUNDC100.J,l)
1 360 NEXT .J
1370 GOTO 10 0
210
SuperFont
---..;;~- Patrick Parrish
211
Sound and Graphics _ _ _ _ __
o DOODLE
E EDIT
N INPUT
R RESTORE CH
H RESTORE CHSET
F COPY
X SWITCH
M MIRROR
V REVERSE
A ROTATE
C CLEAR
I INSERT
D DELETE
W WRITE DATA
Y QUIT
L WAD FONT
S SAVE FONT
P PRINT CH
T PRINT CHSET
When the program is run, these commands are displayed
in menu form on the screen. Above the menu is an 8 X 8 grid
which serves as a work space for redefining each character. To
the right of the grid, the current mode and .. in some cases, a
prompt will be displayed. Below this is printed the entire TI
character set (codes 32-143) with each color subset (eight
characters) depicted by a different background color. (The
colors can be toggled off and on with the Z key.)
Several commands require that you pick a character from
the character set. In these instances, a box shaped sprite,
4
this sprite about the grid with the joystick. Pressing the fire
button will set or clear the point depending on its present
state. You can draw lines by holding down the button while
212
_ _ _ _ _ _ Sound and Graphics
213
Sound and Graphics _ _ _ _ __
214
_ _ _ _ _ _ Sound and Graphics
215
Sound and Graphics _ _ _ _ __
Program I . SuperFont
100 !MEMORY EXPANSION REQUIRED
1113 OIM A$(11t).C$(lS>,N$(112),D(lS),V(S,S),
FR(14),B(14),Zl(20,32):: L=32
216
______• Sound and Graphics
217
Sound and Graphics ______
218
_ _ _ _ _ _ Sound and Graphics
.,
720 Nt;(W - L) =Z $ :: GOSUB 210 :: CALL C HAR(W,Z
219
Sound and Graphics ______•
220
_ _ _ _ _ _ Sound and Graphics
11 9@
..
NEX T . . T = 1 1 2 .. F $ : "" - . PRINT ,. 1 : T.
I
CL OSE • I . - GOS UB I S0 . . IF Pi sec o
-.
$) =67 T HE N 45. EL SE 4 90
1 2tHl IF M:= 11 2 TH E N H= l . . e o s us 1 6 6 13 .. GOT O
490
1 2 1 0 I F M= 11 b TH E N H:@ GOS UB 1 6 6 0.. GO TD ..
490
1 2213 I F M<> 11 1 THEN 4913 ELSE CA LL DEL SPR I TEC
~ 1) :: BOS US 1 8513 :: GO TO 49 13
1 2313 DISPLAY AT C20.2) : Q$ :: ACC EP T ATCB, 14 ) :
os :: 1F os= " " THE N GOSU S 1 B ill : : GO TO 4
913 E LSE GOS US 1 2 60
1 2 4 13 RE TURN
1 2513 ' C QN VER T TO CAP S
1 2613 Z ii =" " :: F OR 1= 1 TO L EN( O $ ) : : F $ =SEG $ <O
$,1,1 ) :: IF ( A S C (F $» 96) . (ASC(F $ ) ~ 1 23) T
HEN FS =C HR$ (ASCCF $ )- L )
1 2713 Z $ =Z $ ~F $ :: N EX T I :: 0 1i =Z$ : : RETUR N
1 2 8 13 ' GET CHAR
12913 CA LL SP RI TE UIl. 143 . FR( 1 4) • .BR f a"- l. BC t 8 +\
221
Sound and Graph ics ______
zzz
_ _ _ _ _ _ Sound and Graphics
223
Sound and Graphics _ _ _ _ __
224
_ _ _ _ _ _ Sound and Graphics
-- NEXT I ::
0$ = "" THEN 1 860 E L S E GOSUB
2290 RETURN
AC CE PT AT ( t . l ) BEEP: O$
l: b~
• • IF
225
·.
Sound Maker -
- - - - - - Frank Elsesser
226
_ _ _ _ _ _ Sound and Graphics
After you have selected the basic tone and found the
combination of parameters which suits you r taste, you w ill be
taken to the modul ation menu. Here, you can make the am-
plitude, frequency, or time change-while the note is play-
ing-to create special effects. The procedure for modulating
frequ ency and time is fairl y straightforward . However, choos-
ing amplitude modulation displays another menu. Three types
of amplitude modulation are available: on/off clicking, pos-
itive ramp, and negative steps. On/off clicking turns the
sound on and off like the busy signal on a telephone. Positive
ramp makes the tone louder with time. Negative steps make it
quieter with time. Positive ramps and negative steps can be
used in your programs to give the effect of an approaching
and receding alien ship.
Experimenting with sounds using Sound Maker is so easy
that you will have the freedom to create sounds you never
thought possible on your TI.
Sound Maker
1 00 CALL CL EAR
110 DIM SI (60 )
1 20 R$="SOUND MA KER"
1 30 CALL SCREE N (14)
140 FOR P = 1 TO It
1 50 CALL SOU ND( 1 50. - 4 , 1 )
1 60 CALL HCHAR(12 . 9+P . ASC(SE G$ ( R$, P ,1» )
1 70 NEXT P
1 80 FOR DE = 1 T O 500
190 NEXT DE
200 CALL CLEAR
2 10 FOR 1 = 1 TO 8
220 CALL COLOR(I, 1 6, 1)
230 NE XT I
240 PRINT .. YOUR TJ CO MPUT ER I S CAPABLEOF MA
KI NG AN ALMOST ENDLESS VARIETV OF SPECIA
L EFFEC T ( 3 SPACES}SOU ND S .": :
250 PRINT" THE PURPOSE OF THIS PROGRA NI S TO
HE L P YOU FIND JUST THERIGHT SO UN D FOR Y
OUR SPEC I ALEF FECT .": :
260 P RIN T" IT ALLOWS YOU TO GENERA T E S IM PL
E TO CO MP LEX SO UN DS ANDTO THEN ADD SPEC I
AL EFF E CT MOD ULAT IONS . " : : :
270 P RINT "(4 SPACES} (ONE MOMENT PLEASE)":
280 REM COMPUTING S - OCTAVES
290 FOR N=0 TO 60
300 Sl( N) :I NT ( 110.( 2 ..... (1/1 2 » " N+.S)
227
Sound and Graphics ______
-.
3 113 CALL S aUND ( - 5S S,SI ( N).4 )
320 NEXT N
33 0 FOR A=0 TO 20 S TE P 5
3 40 CALL Sa UNO (70S.-7,A)
3513
36 0
370
380
399
NEXT A
REH START VALUE S ~ MAIN MENU
CALL CLEAR
Tl = 1000
F 2=3 0999
-
400 A3=3 0
419 F 4 :a300S0
4 20 A5 =3 9
4 30 F6"30000
449 A7 =3 121
45 121 La = 1
4 6121 A9= 3 121
4 7121 PRINT TAB(12 ) ;"M EN U":
489 PRINT TAB( 5, ;"1. SI HPLE TO NES" :
490 PRINT TAB(S';" 2 .NOJ SE TONES";
50121 PRINT TAB(5);" 3 . CO MPL EX TONES" :
5 1121 PRINT TAB(5) ;"4. EXIT ":
52121 INPUT "SELECT NO . ( 1 . 2 . 3 . OR 4 ) ": H
539 ON M GOTa 6513 .1 659 . 2830,51 1 9
54121 REM MO DULATIO N MENU
550 CALL CLEAR
569 PRINT TAB ( 1 9) ; " MODULATIONS":
579 PRINT
580 PRINT TAB (9 ):"1.AMPLITUDE" :
599 PRINT TAB(9);" 2 .FREQUEN CY ":
690 PRINT TA B(9 ) :" 3 .TIME":
610 PR INT TA8(9' ;"4.M AI N MENU":
620 IN PUT "ENTER NUHBER(1,2, 3 ,4)":N S
630 ON NS GOTO 9313.4570 .4 840 . 37 0
640 REH SINGLE TONE GEN
650 CALL CLEAR
660 PRINT TA8(9);"SIMPLE TONES" ;
b70 PRINT
bB0 PRINT " ( PRESS ENTER TO SELECT TONE)":
b90 A3=2
700 FOR N=0 TO b0
71£" F2:5I (N)
729 CALL S OUND(5SS.F2 . A3)
730 CALL KEY(S, K,Z)
7 40 IF K-13 THEN 7713
759 NEXT N
7b9 GO TO 379
-
7713 PRINT "FREQUENCY=";F2:
780 PRINT "TIME - 1000.AHPLITUDE =2" :
790 PRINT "CHANGE PARAHETERS(Y OR N' ? ":
--
228
_ _ _ _ _ _ Sound and Graphics
229
Sound and Graphics ______
230
_ _ _ _ _ _ Sound and Graphics
1780 A9:.. 2
1790 FOR L9 c 1 TO 4
1880 CALL SOUND(Tl . - LB.A9)
1810 PRINT TAB(1 2) ;"TYPE~";L8:
1820 NEXT La
1830 PRINT "SELECT TYPE~TIME (Y n R 1\1) 7" :
1840 CALL KEV(0,K.Z)
1850 IF 2+1=1 THEN 1840
1860 IF K=78 THEN 1 6 40
1870 IF K=S9 THEN 1880 E LSE 184 0
1980 INPUT ·TYPE=~:L8
1890 INPUT MTIME=":TI
1900 CALL SOUNDeTI . - LB.Aq )
1910 PRINT TAB CB) :"TR V AGA I N (Y OR Nl?" :
1920 CALL KEY(0.~, Z)
19 3 0 IF 2+1=1 THEN 192~
1940 IF K=B9 THEN t B8 ~
1950 IF K=78 THEN 550 ELSE 192 0
1960 REM TYPE 4 N WIT H TO NF
197 0 CALL CLEAR
1980 PRINT N PERIODIC NOI S E WIT H TO NE " :
1990 PRINT "(PRESS ENT F.:R TO S ELECT TO NE )":
200(11 Tl=2000
2910 A= 3 0
2020 A9= 2
2 /i!1 3 8 Z=0
2040 FOR N=0 TO 60
20'50 F6 = Sl (N )
2 060 CALL KEY(0.K . Z)
2070 IF K=13 THEN 2 120
2 0813 CALL S OUND(Tl.F 6, A,F6 . A . F6.A . - 4,A 9 J
213913 L8=4
2 11313 NEXT N
2 1113 GOTO 16513
21213 CALL CLEAR
21313 PRINT" TYPE - 4 PARAMETERS":
21413 PRINT "CAll SOUNDCT1.F.3e.F . . . - 4.2 )" :
2 1513 PRINT "TIME=200e " :
21613 PRINT "FREQUENCV=";F6:
21713 PRINT CDEPRES S ""R""TQ REPEAT) " :
2180 PRINT "TRV NEW PARAM E TERS(Y OR N l?" :
21913 CALL SQUND(Tl,F6,30 . F6,3e,F6,30,-4 . A9)
221313 CALL KEV(e,K,Z)
22113 IF 2+1=1 THEN 221313
2220 IF K=B9 THEN 22513
22313 IF K=82 THEN 21913
22413 IF K: 7 8 THEN ~~0 ELSE 22130
2250 INPUT "TIME=":Tl
22613 INPUT "AMPL=":A9
231
Sound and Graphics _______
227 0 GOTO 2 1 80
22811'1 REM WHIT E N GEN
2290 CALL CLEAR
2300 PRINT TAB (9) : "W H ITE NOISE" :
23HI Tl =2000
232 0 A9=2
233 11'1 F OR L B=5 TO B
23 4 0 CALL SOUNO(T l. -L8 .A 9)
23511'1 PR INT TAB(9):"TYPE = ": LB :
2360 NEXT L 8
237 0 PRINT MSEL ECT T YPELTI ME(Y OR N J~" :
2380 CALL KEY(0 . K . I)
239 13 I F Z+I=l THEN 2380
2 4 00 IF K=78 THEN 1 650
2 41 0 IF K=B9 THEN 2 4 20 E LSE 23811'1
2 4 20 IN PUT "TYPE = ":L8
2 43 0 INPUT " TIM E=" : Tl
2 44 11'1 CALL SOUNO(T l .-L8 . A9)
2 4 50 PRINT TAB(B) : " TRY AGAI N CY OR N )':""':
2 4 611'1 CALL KE YCI1'l . K.Z )
2 4 70 IF Z+I = 1 THEN 24611'1
2 4 811'1 IF K=89 THEN 24211'1
2 49 0 IF K=78 TH EN 5511'1 ELSE 2 4 6 11'1
25 11'10 REM WHI TE N WITH TONES
25 1 11'1 CALL CLEAR
25211'1 P RINT "{ 3 SPACES } WH I TE NOISE WI TH TONES
M :
232
_ _ _ _ _ _ Sound and Graphics
233
Sound and Graphics _ _ _ _ __
3 19121 NEXT L
3 2 00 IF Z+I = l THEN 3 210 EL S E 3 600
32 10 D4$ = STR$CA 3)
32 2 0 CALL HCHARC 2 0, 2 5, 32 )
3 2 3 121 FOR L = l TO LEN CD4$ )
32 40 CALL HCHAR (2 0 , L~ 23 . A S C (S EG$CD4$ . L.l») __
3 25 0 NEXT L
326 0 IF Z+I = l THEN 327 0 EL S E 3 60 0
3 270 D5$ =S TR$(F4)
3 28121 FOR L= l TO LENCD5$ )
32 90 CALL HCHARC 2 1,ll, 32 )
33 121121 CALL HCHAR( 2 1,L+ 7, ASC( S EG$CDS$,L, 1» )
33 1121 NEXT L
332 121 IF Z+I = l THEN 333 121 ELSE 3 600
3330 D6 $ = STR$(A5)
33 40 F OR L=1 TO LEN ( 06$ )
33 59 CALL HCHAR(21,14 ,3 2)
3360 CALL HCHAR( 2 1.L+12.ASC(SEG$(D6$, L , 1» )
337121 NEXT L
3380 IF Z+l = l THEN 3390 ELSE 3 600
3390 D7$=STR$(F6)
341210 FOR L = l TO LEN(07$)
34 1121 CALL HCHAR(21,19,32)
3 420 CALL HCHAR(21,L+15,ASC(SEG$(07$,L, I » )
343121 NEXT L
34 4121 IF Z+I=l THEN 345121 ELSE 3 6121121
345121 08$=STR$(A7)
3460 FOR L=l TO LEN(08$)
347121 CALL HCHAR(21,22,32)
3 480 CALL HCHAR(21,L+2I21,ASC(SEG$(D8$,L,I»)
3490 NEXT L
35121121 IF Z+I=1 THEN 351121 ELSE 361210
3519 D9$=STR$(L8)
3520 CALL HCHARC21 , 25,ASCC09$»
353121 I F Z+ l =1 THEN 354121 ELSE 369121
3540 D0$=STR$(A9)
355121 FOR L = l TO LENC00$)
356121 CALL HCHARC21,28.32)
3 570 CALL HCHARC21,L+26,ASC(SEG$(D0$,L, 1»)
358121 NEXT L
3 59121 REM SEPARATE UP - ON&EXIT
360121 CALL KEVCI2I,K,Z)
3 61121 IF K= 69 THEN 559
3 62121 CALL KEY (121, I,J)
36 3 0 IF 1 < > 1 3 THEN 3 660
3 640 GOSUB 4140
365121 GO TO 3 61313
3660 IF Z+l=l THEN 36121121
3 67121 IF K ) 32 T HE N 3 68121 ELSE 3 600
3680 IF K=42 THEN 453121
234
_ _ _ _ _ _ Sound and Graphics
235
Sound and Graphics _ _ _ _ __
41 70 IF N2 ( 1 THEN 3150
4180 N2 = N2- 1
4190 F2=SI(N2)
4 200 GOSUB 4140
4 210 GOTO 3 1 50
4220 ON (K-32)GOTO 4230,423121,4270,4310,4360,
4450,440121,4490
4 230 IF Tl ( 200 THEN 309 0
4 240 Tl=TI - 100
4250 GDSUB 4140
4 260 GOTO 312190
4270 IF A3 ( 1 THEN 32 1 0
4280 A3=A3 - 1
429121 GOSUB 4140
4 300 GOTO 3210
4310 IF N4 ( 1 THEN 3270
4 320 N4 = N4 - 1
4 330 F4=SlCN4)
4 3 4121 GOSUB 4140
4350 GOTO 327121
4 360 IF A5 ( 1 THEN 3330
4 370 A5=A5 -1
43Bf3 GOSUB 4140
4 39121 GOTO 3330
4400 IF N6 ( 1 THEN 3390
441121 N6= N6 - 1
4420 F6=Sl(N6)
44 3121 GOSUB 4140
4440 GOTO 339121
445121 IF A7 ( 1 THEN 3 45121
4460 A7=A7-1
44 70 GOSUB 414121
4480 GOTO 3 45121
4490 IF A9 ( 1 THEN 35 4121
4500 A9=A9-1
45UI GOSUB 4140
45 2 0 GOTO 3540
45 3 0 IF LB ( 2 THEN 35 10
4540 LB=L8 - 1
4550 GOSUB 4140
4560 GOTO 35 10
4570 REM FRED MOD
4580 CALL CLEAR
4590 PRINT ~(3 S PA CES} FREDU E NCV MODULATION":
236
_ _ _ _ _ _ Sound and Graphics
2,7
Sound Shaper
- - - - - - Steven Kaye
TI Translation by Patrick Parrish
Sound Shaper
IS9 CALL CLEAR
110 CALL SCREE N (lS)
129 PRINT TA8(7): "SHAPING TI SOUNDS"
1 3 9 FOR T= 1 TO 6
140 PRINT
1 50 NEXT T
160 PRINT "CHOOSE:"
170 PRINT
180 PR INT
190 PRINT TA8 (4);N1) SHAPED MUSICAL NOTE S "
238
_ _ _ _ _ _ Sound and Graphics
20. PRI NT
2 10 PRI NT TA B(4): "2> ECHO"
22. PRINT
23. PR I NT TAB(4): "3) QUIT"
24. PRINT
25. INPUT A.
269 IF (VAL(A.' C l)+CVALCA.» 3) THEN 2~0
279 ON VAL(A.)GOTO 298.529.698
288 RE M THIS PART PRODUCES "SHAPED" MU S ICAL
NOTE S
299 CALL CLEAR
399 CALL SCREE N (13)
3 19 PR INT TA8 (3l ;"' S HAPED MUS I CA L NO TES ."
32 9 FOR T = I TO 1 9
33 9 PR INT
3 4 121 N EXT T
35 9 PRI NT "ENTER RISE AND FALL T IME S -
369 PRINT "USE VALUES GRE ATER THA N ZERO";
370 PRINT
3 89 I NPUT R . D
3 99 IF (R-0)+(D-0) TH E N 3 89
480 FOR Fs110 TO 889 S TEP 39
4 1 9 FOR 08 =39 TO £I STEP -SI R
429 C ALL SOUNOC-10.F.DBl
4 30 NEXT 08
44 9 FOR 08 -9 TO 39 S T E P SID
4 59 CAL L SOU ND( - 10.F.DB )
460 NEXT DB
4 79 FOR T - 1 TO 59
489 N EXT T
4 99 N EXT F
509 GOTO 199
519 RE M THIS PART CREATES AN ECHO EFFECT
529 CALL CLEAR
539 CALL SC REEN ( 14 )
5 49 PRINT TABCS) ;"' EC HO EFFECT , .
550 FOR T- l TO 1 2
560 PRINT
570 NEXT T
580 FOR F ~ 110 TO 880 ST EP 3 0
599 FOR oB : 1 TO 3 0
600 CA LL SOU No (- 1 0~F~ oB )
610 FOR T- 1 TO 10
629 NEXT T
630 CALL S OUNDI-10,990-F,DB)
640 FOR J:1 TO 1 0
650 NEX T J
660 NEXT DB
670 NEXT F
680 GOTO 10 0
690 END 239
The Mozart
Machine
- - - - - Donald J. Eddington
TI Translation by Gregg Peele
240
_ _ _ _ _ _ Sound and Graphics
TI Mozart
1 00 D IH X(14 , 9)
1 1 0 RE M THE TICLANG AMAZ I US MOZART
120 CALL CLEAR
1 3@ CALL SC REE N ( t 4 )
140 PRINT "{3 SPACES}WELCOME! I AM TICLANG N
...
431il
.5.
4 60
DATA 196,659 . 523 . 262 . 392 . 659,330,523, 196
DATA 2 20 . 523 . 587,262 . 784,587.294,523,220
DATA 220 ,440,58 7 ,220 . 52 3 . 494, 29 4 . 440,262
DATA 220 . 659.784.262,587.523.294,494,220
DATA 220 . 523 .494.26 2 . 440 . 494, 330 . 523 ,220
'7. DATA 220,523,494 . 262, 440.4Q4 ,330 , 523 ,262
'8. DATA 196,494,52 3 . 2 47.58 7,5 87,29 4, 587 , 2 94
490 DATA 1 96,587,523,220,440,440,294, 4 40, 2 20
500 DATA 1 96 ,659 , 58 7 , 262 , 523,5~3,330,523,262
510 P =25 0
520 DATA 1 . 3,6 .2. 1 .4.6 . 2,3 ,4,1, 5, 1 , 4, 6 ,7 , 1,4
. 6,2, 1. 3 . 6 ,9
5 30 DATA 1 . 1 . 4. 5.1.4 . 6 . 2 . 3 . 4.1 . 5 . 1 . 4.1.5 .1 ,4
. 6,9
541il DA T A 1.4. 6 . 2 . 3 . 6 . 1 . 5 .1.4.6. 7 ,3 . 4,6, 2 . 1 , 4
. 3,7 ,1.4 ,6 ,9
241
Sound and Graphics ______
242
_ _ _ _ _ _ Sound and Graph ics
243
L
6
A Beginner's Guide
to Sprites
- - - - - - Gary K. Hamlin
Sprites are easy to create and use. They enhance the graphic
displays and make smooth moving objects simple to cOlltro/,
This program requires Extended BASIC.
An exciting feature of most personal computers is their color
graphics capability. Even if the computer was purchased for
financia l management or complex mathematical computations,
it's hard to resist experimenting with graphics. Defining
and manipulating your own characters-from oddly shaped
"dood les" to those resembling actual objects-can be a lot of
fun, and can have practical applications too.
Graphics are quite easy to use on the Tl-99/4A, with TI
BASIC's series of built-in graphics subprograms. Once they are
learned, subprograms used with sprites are also easy. Sprites
require the addition of the TI Extended BASIC cartridge, and
will greatly enhance the computer's possible graphics
applications.
Sprites Vs. Characters
A sprite can be one of the characters from the TI character set
or can be made from user-created dot patterns, just as is done
in standard BASIC, using the CHAR subprogram. Sprites,
however, are more versatile than standard BASIC characters.
Sprites can be positioned at 49,152 different screen locations
(192 rows by 256 columns); standard characters have only
768 possible screen positions (24 rows by 32 columns). This
permits faster and smoother character movement, a Significant
advantage in game programming.
The CALL CHAR statement is used in defining Extended
BASIC sprites much as it is in standard BASIC character defi-
nition. The same 8 X 8 dot grid and hexadecimal on/off
codes are used (Figure 1), but sprites can occupy up to four 8
X 8 dot blocks. The resulting hexadecimal code pattern identi-
fiers can contain up to 64 characters. The computer will auto-
matically reserve four blocks for each sprite, whether or not all
247
Sprites _ _ _ __
, -
- IS
248
- -_ _ _ _ Sprites
Deflninc a Sprite
Sprite characters should he assigned character codes divisible
by four if they are to occupy more than one of the four blocks.
This is less critical for single-block sprites, but the character
code assigned to a single-block sprite will affect which
blocks-A, H, C, or D-the sprite will occupy. The computer
will always assign a character code divisible by four to block A.
The order of the blocks, as shown in Figure 2, is also criti-
cal when writing out the pattern identifier of a multiple-block
sprite. If the order is not observed-and if block A's character
code is not evenly divisible by four-the four segments of the
sprite will become jumbled when displayed on the screen. Al-
ways begin with the pattern identifier for block A, at the up-
per left, proceeding to the lower left (8), upper right (C), and
concluding with block 0 at the lower right.
It should also be kept in mind that in program references
to the screen location of a sprite, the specified location identi-
fies the dot occupying the upper-left corner of the four re-
served blocks (shown as the shaded dot in block A, Figure 2).
This is true whether or not that dot constitutes a visible part of
the sprite.
The sprite mapped out in Figure 3 is intended to occupy
four 8 X 8 blocks. To illustrate the proper sequence of the
hexadecimal code pattern identifiers, the pattern identifiers
will be referred to as string variables with the letter of the
variable corresponding to the letter designation of each of the
four blocks. The program statements would be:
1~~ A~=·01 020 4 020 1 23~68D"
11 0 B~=·8D~6230102040201·
120 C~=·8040204080C 46ABl·
130 D~="BI6AC4804020408~"
140 CALL CHAR(96,A~&B~&C~&D~)
249
Sprites ____ _ _
Hexadecimal Code
01 80
02 40
04 20
02 40
01 80
23 C4
56 6A
8D B1
8D B1
56 6A
23 C4
01 80
02 40
04 20
02 40
01 80
250
_ _ _ _ _ _ Sprites
Hex.
Code
18
18
18
3C
3C
3C
66
C3
251
Sprites ______
on the screen. Once the RUN command is given, line 200 will
cause the program to continue running until CLEAR (FCTN 4)
is pressed.
16. CALL CLEAR
17. CALL SC RE E N(l S )
18. CA L L S PRITE(#1.96.7,95.7S)
19. CALL S PRITE(#2.90 . 2 . 170,125)
2 •• GO TO 200
252
_ _ _ _ _ _ Sprites
All other program lines will remain the same. After making
the changes, try running the program with both magnification
factors three and four used in line 200. The two sprites will
now appear as intended. For the remaining program demon-
strations, the magnification factor should be set at three.
Where's the Sprite?
Once sprites have been correctly displayed on screen, various
subprograms can be CALLed to manipulate them. Motion can
be added, the appearance of a sprite can be altered, and infor-
mation can be obtained about character pattern identifiers,
sprite location, and the distance between sprites.
The POSITION subprogram is used when the numeric
values of the screen location of a sprite are desired. In the
CALL POSITION statement, sprite number is fi rst specified,
followed by two numeric variables. When the statement is
executed, the numeric variables are set equal to the values of
the sprite's row and column, respectively. Values returned are
for the location of the upper-left corner of the four block sprite
allotment.
The following changes and additions to the demonstration
program will illustrate the operation of the POSITION
subprogram:
21@ CALL POSITIONCMI,DRl,oCl)
220 CALL POSITIONCM2.oR2 . oC2)
23~ PRINT TAB( b) ; "ROW"."COL"
240 PRINT "Ml; ";oRI,DCI
250 PRINT ""'2 ; ": oR 2 , DC2
260 STOP
253
Sprites ______
254
_ _ _ _ _ Sprites
Moving Sprites
CALL WCATE is used to change the screen location of a
sprite. It does so immediately upon execution of the program
line, producing an abrupt change rather than gradual motion.
The syntax is CALL WCATE(sprite number,row,column).
2 10 CALL LOCATEC.2, 1,200)
220 FOR DELAY = l TO 1000 : : NEXT DELAY
230 CALL LOCATE(.2,15~15)
2 40 FOR DELAY = l TO 1000 : : NEXT DELAV
250 CALL LOCATE(~2,170,125)
260 GOTO 210
270 REM DELETE THIS LINE
255
Sprites _ _ _ _ __
These lines move the spaceship sprite from its original po-
sition first to a point near the upper right of the screen, then
near the upper left, then back to its original location. The pro~
gram will continue to run until CLEAR (FCTN 4) is pressed.
If a change in the character pattern is wanted without
otherwise affecting the sprite, the CALL PATTERN statement
is used. It can be used to completely reshape a sprite or to
make more subtle changes in appearance. When combined
with other statements, it can be used to simulate the visual
effects of motion. By changing the sample program lines as
follows, the spaceship sprite will change from vertical to hori~
zontal orientation, then back again.
2 10FOR 0=1 TO 1000 : : NEXT 0
220 CALL CHAR(1 40. "80C0783F3F7BC080")
230 CALL PATTERN(#2, 140)
2 40FOR 0=1 TO 1000 :: NEXT 0
250 CALL PATTERNC # 2.130)
260 GOTO 2 1 111
256
_ _ _ _ _ _ Sprites
257
Sprites _ _ _ __
258
_ _ _ _ _ _ Sprites
259
Sprites ______
Demonstration Procram
These are the essentials of sprite programming, and the
demonstrations used are only representative of what can be
done with sprites. After experimenting with the different sub-
programs, you'll discover how to best use sprites in your own
programs.
Below is a complete listing of the sprite demonstration
program.
Sprite Demonstration
100 CALL CLEAR
110 PRINT TAB(S ) :" • ••• SPRI TE OE MO***."
120 PRINT :: P R INT "DE S IGNED TO ACC OM P AN Y"
13 0 PRINT ",," A BEGINNER ' S GUIDE TO
( 6 SPACES } SPRITES IN TI EXTENDeD
{S S PACES}BASIC .,,',
170 FOR 0 = 1 TO 1000 :: NEXT 0
180 CALL CLEAR
1 90 PRINT "THIS DE MON S TRATION FOLLO WS THE 5
EDUENCE OF THE ARTI CL E ."
200 PRINT : : PR IN T "THE PRO GRAM S TEP S US ED A
RE THE SA ME AS THO S E US ED IN {3 S PACES } T
HE ARTICLE."
2 10 PRINT :: PR I NT " AT THE END OF EACH DEMO .
A TONE WILL SOUND. "
220 PRINT :: PRINT ~THE N PRESS LETTER Q TO C
ON - TINUE WITH THE NEXT DEMO."
230 FOR 0 = 1 TO 1 000 :: NEXT D
2 40 CALL CLEAR
250 A$=·0102040 2 0t~ 3 S68D"
2 60 B$=HBOSb2 3 0 102040 2 0I"
270 C$="8040204080C4 6 AB1"
280 D$="BlbAC48040204080"
290 CALL CHAR ( 9b.A$tB$& C $~D$)
300 CALL CHAR ( 90." 1 81918 3 C3 C3C 6 6C 3 '"
310 CALL SCREE N (15 )
320 CALL SPRITEC.l . Q b, 7 .95.7S )
330 CALL SPRITE(.2,90.7, 1 7 0,125)
335 FOR 0= 1 TO 500 : : NEXT 0
3 40 Gosue 2'500
350 CALL MAGNIFV(2 )
3b0 DISPLAY AT( 3 . 3 ): -MAG. FACTOR 2 "
370 FOR 0=1 TO 500 :: NEXT 0
260
_ _ _ _ _ Sprite,
261
Sprites ______
262
______• Sprites
- 263
Sprite Editor
- , . ; ; , - - - Larry Long
At this point, you are given several options. You can mag-
nify your newly constructed sprite (M key), change its color (C
key), change its background color (6 key), or set it in motion
(E, 5, D, X keys). If you are not pleased with the sprite's
shape, you can modify it by striking the T key or (if the
changes required are quite drastic) simply press the A key to
start with a fresh grid. On the other hand, if you are satisfied
with your sprite and its color and directional parameters, press
the L key to create th e BASIC statements needed to achieve
these effects.
If using the sprite editor is your on ly concern, then skip
the Test of this article and go straight to Program 2 and enjoy
this easy access to sprites.
Lines
100-260 Set up screen display.
270- 460 The main loop of the designing portion of the program.
470-680 Evaluate the design, put its values in an array, read the
values in the array, convert them to hexadecimal num-
bers, and then build a 64-character string to describe the
sprite pattern.
690-770 Put the sprite on the screen and display new program
instructions.
780-930 Main loop of the implementation portion of the program.
940-980 Change size of sprite.
1000-1150 Display a listing ofithe sprite program.
1160-1220 Change the color of the sprite and screen.
266
_ _ _ _ _ _ Sprites
1 3. C I '"'7
14 . CALL CHAR lle0 ," ")
1 5. CALL CHAR(10 1, MFFFFFFFFF FFFFF FF " )
1 •• CALL CHAR( 10 2 , "FFFFC 3 C3C3C3F FFF")
1 7. CALL COLOR(9 . 2 . 16 )
lB. CALL CLEAR
1'. DISPLAY ATCI. Ie': "SPRITE EDITOR N
2 •• FOR R=l TO 1 6 :: CALL HCHAR C4+R.2. l ee, 16
) : : NE XT R
2 1. CALL MAGNIFY(t )
2 12 IF K- 84 THEN GOTO 2 1 7
215 CALL SCREE N ( S)
217 CALL DELSPRtTECALL)
22. CALL SPR IT E ltt28, 10 2 , 14 ,32,8)
225 C AL L H C HAR( 2 1.1, 32,3 1) : : C ALL HCHAR(22 , 1
,3 2,3 1 )
23. DISPLAY AT(22,Z':"E = UP X- DOWN S-LEFT D= R
IGH T"
24. DISPLAY ATC2 3 . 2) :"PRE S S 1 - PIXEL ON ,121
- OFF"
25. DISPLAY AT(24.2) : "PRESS P TO D1 SPLAY S PR
ITE"
2 •• R "' l : : C= l
2.5 KHAR - t0 0
27. CALL KEYeS . K,S)
27 1 IF S=0 THEN 27.
272 IF K:: 4 8 TH EN K HAR = 10 0
27 4 IF 1<= 49 THEN KHAR= 101
2B.
2 ••
IF K::83 TH EN C=C- l ·
IF K:68 THEN C""C+ l · . GOTO 320
.
GOT a 32 121
- 4 ••
4 7.
4B.
GO TO 270
CALL DELSPRITE(ALL)
CALL HCHAR( 2 1 , 1, 32, 128)
4'. DISPLA Y AT(22 , 2): "PLEASE WAIT WHI LE I TH
IN K ."
5 •• FOR R=l TO 16
51. FOR C= I TO 1 &
52. CALL GCHAR(4+R,1+C,GC)
5 3 . GC "' GC - 100
5 4 . B(R, C )=GC
267
Sprites ______
550 NE XT C
560 NEXT R
570 HEX$ = "012 3 456 7 89ABCOEF"
580 M$ =" "
59 13 FOR R= I TO 1 6
600 LOW=B(R,S)*B+BCR,6'.4 +B (R!7l t 2 +B CR , Bl+ l
610 HIGH = BCR, 1)t 8+BCR . 2) t4 +B(R,3)t2+S(R.4)+1
629 M$ = MS&SE GS(HEX~. HIGH. l '&SE GSCHEX$,LDW . 1)
63 9 NEXT R
649 FOR R= l TO 16
65£1 LOW=B(R, 1 3 ) * 8+BCR, 14 ) t4 + B(R, IS ) t 2+ B CR, 16
) +1
66£1 HIGH=B(R,9) t 8+BCR,I@)t4+BCR,11)'2+BCR.12
) + 1
6 70 M$ = HS& 5EG S (HEX$. HIGH. 1 ) t.SEG $ (HEX $, LO W, 1 )
68£1 NEXT R
699 CALL CHAR(104,MS )
790 CALL MAGNIF V(3)
7 10 MM "'3
720 M= 4
730 CALL SPRITE< # 1.104. C l. 50 .1 70 .0. 0)
7 40 DI S PLAV AT C2 1. 2) : "C COLOR M MAGNI FV T
EDIT"
750 DISPLAY AT C22 . 2l :"A ERASE Q QUIT B SAC
KG RD"
760 DISPLAY ATC23,2): " E- UP X-DO WN S- LEFT O=R
IGHT "
770 DISPLAY AT( 24 .8 ) : "L L I S T S PROGRAM"
780 CALL KE Y< 0.K,S)
790 IF K=76 THE N GOTO 100 0
B00 IF K=8 1 THEN GOTO 99 0
B 10 IF K=65 THEN GOTO I ••
B12 IF K=66 THEN GOSUB t 20111
815 I F K=84 THEN GO TO 21.
B2. IF K=77 THEN GOTO 0 4 .
B3. IF K=67 THEN GO T O 1 160
B4. IF K=83 THEN H=H - 2
B5. I F K"'68 THEN H=H+2
B•• IF K:69 THEN V= V- 2
B7. IF V=88 THEN V=\.' + 2
BB. IF V > t 2 0 THEN V= 1 2 0
9 0. I F V< - 120 TH E N V=- 1 2 13
0 •• IF H ) 1 2 0 THEN H= 12f11
0 1. IF H < - 12~ THEN H=- 120
920 CA LL MOTIONUtl. V.H l
930 GOTO 7B.
...
04.
OS.
97111
CALL MA GN IFY CM)
MM = M
IF M=3 THEN M= 4 E L S E N =:',
FOR 0 =1 TO 2~ :: NE XT 0
268
_ _ _ _ _ _ Sprites
269
Runway 180
Using Sprites in Extended
BASIC
- - - - - - James Dunn
Creating Sprites
Certain considerations must he taken into account before
spri tes are created. If a special graphics character is to be used
for the sprite, the character must be created by use of CALL
270
_ _ _ _ _ _ Sprites
271
Sprites ______
Sprites in Motion
Now that the sprite has been created, there are two ways of
moving it around the screen. Let's call these two methods ab-
solute and relative. The absolute method uses exact row and
column positions via the CALL LOCATE command. The rel-
ative method uses row and column motion values via the
CALL MOTION command.
The absolute method uses a loop with CALL JOYST to in-
crement row and column variables, and then a CALL W -
CATE to move the sprite one step each time the loop is
executed. This is analogous to nonsprite methods of anima-
tion. Th e drawback in using this method is that the sprite does
not move independently; the main program causes the move.
A modified form of this method is used for the stall subroutine
(line 1470) and the new approach routine (line 1380).
The relative method is similar, using a loop with CALL
JOYST to increment row and column motion variables which
are used in a CALL MOTION command. This allows the
sprites to continue moving independently of the main pro-
gram. By this method, the runway stripe is moved horizontally
only (line 680) and the aircraft vertically only (also line 680).
The sprite's shape may be changed anytime during the
program by using CALL PATTERN to substitute a different
ASCII character number and therefore a different pattern.
When the fire button is depressed (line 1130), the aircraft
landing gear comes down (line 1190). The pattern is changed
again if the aircraft crashes (line 1720).
Testing for Game Conditions
During the operation of the program, it may become necessary
to test for certain conditions. For example, we see if the air-
craft has touched down on the runway (line 690), if the tower
has reached the left side of the screen (line 700), or if the air-
craft is going off the top of the screen (line 710). CALL
CDINC is used to test for these conditions,
However, there is a problem with this method. Since the
main program tests for coincidence only when CALL COINC
is executed and since the sprite moves independently of the
main program, it is quite possible to miss an exact coincidence
when it occurs. For this reason a tolerance factor is induded in
CALL COINe. So the test is really for a range of + or - tol-
erance. If the tolerance is too large, coincidence can be re-
272
_ _ _ _ _ _ Sprites
273
Sprites ______•
274
_______ Sprites
275
Sprites _ _ _ _ __
117.110
DISPLAY ATCII.S'SIZE(201 : USING 800:RE
10 20RETURN
10 317.1
CAL L HCHAR(7,S,33 , 27);: RETURN
10417.1
CALL HCHAR(9 . 5 . 33 . 27): : RETURN
105£1CALL HCHAR(II.S,33 . 27) :: RETURN
1060 DISPLAY AT{9.5)SIZE(201 ; USING "LIFT OFF
" : : CALL HCHAR(I 1,5,33,27) : : RETURN
1070 DISPLAY AT(3. 117.1) : USING ·· END OF RUNWAY"
:: DISPLAY ATCS. 10):UsING "NEW APPROAC
H" : : DISPLAY ATC7, 10) :USING ""NECESSARY
117.1 80 RETURN
117.19 0 PRINT "T HAT'S 5 PASSES AT TH E" :: PRINT
:: PRINT "RUNWAY. TURN IN YOUFf" ;: PRI
NT :: PPINT "PILOT LICENSE AND PUT '·:
1100 PRINT "SO ME ONE ELSE IN THE" :: PRIN T::
PRINT "COCVPIT'· :: PRINT ;: RETURN
1110 DISPLAY ATC7,9'BEEP SIZE(217.1) : USING 860
:: RETURN
1120 REM JOYST/ LANDING GEAR
1130 CALL KEY(I,RV . ST): : IF RV:19 AND LG=0 T
HEN 11917.1
276
______• Sprites
- 277
Sprites _ _ _ _ __
278
_ _ _ _ _ _ Sprites
279
--'
7
TI Disk DeIeter
- - - - - - Patrick Parrish
283
Utilities _ _ _ _ __
284
_ _ _ _ _ _ Utilities
285
Utilities ______•
Disk Deleter
1~0 DIM A$CI27) .EC 1 27)~FC I 27).G( t 27) .H$(127)
,PAGE(4)
I1G X$(l)="DIS/FIX"
129 X$(2)="DIS/VAR N
130 X$(3)="JNT/FIX"
140 X$(4)="INT/VAR"
159 X$(5) = "PROGRAM"
16121 PAGECl)=1
17121 PAGE(2) =3 7
189 PAGE(3)=7 3
19121 PAGE(4' =11219
290 GOTO 390
210 FOR T=I TO LENCR$)
220 CALL HCHAR (PROW, PCOL+T . AS C (SEG$ ( R$. T, I) )
)
239 NEXT T
240 RETURN
250 OPEN #l: "DSK"&STR$CM)&N.". INPUT ,RELAT IV
E,INTERNAL
26121 INPUT #1 : B$ . C . C.A
279 IF 0=0 THEN 38G
280 PROW=I
290 R$=STR$(C - A)
399 CALL HCHARCP ROW . 2 1, 32 . 3)
319 PCOL=23-LENCR$)
32 0 GOSUB 210
330 R$=STRt;CA)
349 CALL HCHA R(PROW ~ 28.32 . 3)
350 PCOL =3 0 - LENCR$)
360 GOSue 210
370 0=0
380 RETURN
385 REM CHANGE THE P ARAMETERS IN L INE 390 TO
SU IT YOUR PRINTER (SE E YOUR MANUAL)
390 OPEN # 2 : "RS2 32 .8A =9 6G0 . PA=N.OA=8"
400 CALL CHAR (128 ." 080C0EFFFF0E0C08·')
419 CALL CHARC1 36. " H )
420 CALL COLOR(14.1.1 )
439 CALL CLEAR
440 CALL SCREEN(9)
450 FOR 1=9 TO 1 2
460 CALL COLORCI, 2 . 1)
470 NEXT 1
480 IF FL=0 THEN 56121
286
_ _ _ _ _ _ Utilities
57 0 HI=2
580 PRINT DRIVE NUMBER { 1 - 3 { ,} ? ";
590 CALL KEY(0,K,S)
600 IF (S :: 0)+«K < 49)+(K } Sl»THEN 590
619 M=K - 48
620 CALL CLEAR
639 CALL SCREEN(1S)
640 FOR 1=9 TO 1 2
650 CALL COLOR<I,16, 1)
66" NEXT I
679 GOSUS 250
680 PRINT TAB(3';" . . . READING OIRECTORY"
690 FOR 1 = 1 TO 127
700 INPUT .J:AS(II,E(I) . F(I).G(I)
71121 IF LEN(AS(I» <> 0 THEN 7 3 9
729 1=127
730 NEXT I
740 SC = l
759 LAST = 20
769 1=1
770 ROW = 3
7 80 COL:: 3
79121 CALL CLEAR
800 CALL 5CREEN«SC+IJt2+1)
819 PRINT "DSK:";BSjTA8(16J;"U;";TA8(21 - LEN(
STRS(C - A»);C-A;TAB(23J;"F:";TA8(2B - LEN(
STRS (A) ) ) ; A
82121 PRINT TAB(21);"PAGE .";SC;
8 3 121 IF A5 = 1 THEN 85121
84121 IF (LEN (AS (I) )=0) + «(1= 3 7) + (1=73) + CI=U,9)
)THEN 95121
850 AS=12I
860 PRINT TAB(1);CHRS(136};
870 IF E(I»=12I THEN 89121
880 PRINT "* ";
890 PRINT TAB(3);AS(J);TAB(lS);CHRS(136);
900 IF E(I+l»=12I THEN 92121
91121 PRINT "*";
9 2 121 PRINT TAB(17);A$(I+l)
93121 1 = 1+2
940 GOTO 840
287
Utilities _ _ _ _ __
288 -.
_ _ _ _ _ _ Utilities
14 30 ROW:::3
1440 CALL HCHAR fOLDRO W. COL. 136)
145121 GOTO 1 700
1460 IF K<) bS THEN 1520
1470 A5 - 1
1480 SC=SC+l
1490 IF (SC < :HI) ~ (LEN(A~( I » 0) T HEN 770
15 0 0 SC""SC- l
1510 GOTO 119 ("
15 20 IF K <~ 6b T HEN 1 600
15 3121 A S- !
1540 SC=SC- l
1550 IF SC=0 THEN 158 0
1'5 60 I = F'A GE< 5Cl
1 570 GOTO 77 0
1580 SC=- J
1 590 GOTO 119 111
1 61210 I F K=75 THEN 1 720
1610 I F ~=8' TH E N 2050
.1 6 313 CLOSE
164121 FL = l
.1
1 6 2 121 I F K() 67 THEN 1 660
165£1 GOTO 4 30
166 0 IF ~ :<) B l THEN 1 190
1 6713 CLOSE III
1 680 CLOSE 11 2
169 0 STOP
1 70121 CALL HCH ARCR QW. COL. 128)
1 710 GOTO 1 190
1~20 J=(SC- l ) . 36 ~ «RO W -2) * 2- 1 )-(COL= 1 7)
1 7 313 IF E (J ) <=0 TH EN 1 1913
1 740 C .. .. ""
1750 FOR T-2 TO 1 1
1760 CAL L GCHAR(ROW.COL+T . Z)
1 770 IF (Z >32)+(T (> 2'THEN 18 1 0
1 7801=11
1 79 0 FL::J
1 800 GOTO 185121
181 0 IF Z <>3 2 THEN 1840
18 20 T = 11
18 30 GOTO 1850
18411'1 C$ =C .&CHR${ Z)
1 8511'1 NEXT T
18611'1 IF FL -0 THEN 1 890
18 70 FL=e
18Se GOTD !!g e
18 911'1 PROW "2 1
1900 PCOL =5
19111'1 R$ "' "ARE YOU SURE (Y IN )?"
19 211'1 GOSUB 2 19
269
Utilities ______
2~ -
Master Disk
Directory
Raymond 1. Herold
291
Utilities _ _ _ _ __
292
_ _ _ _ _ Utilities
-- 1 WORKDlSK
2 RHSOFTWARE
3 EDITASSMWK
7
11
5
256
102
252
, ASSMDEBUG 7 9'
5 ASSMGAMES2 3 301
6 CJFMASTERI 8 158
7E/A 11 1
8 E/A'PARTB 9 5
PRESS ENTER TO CONTINUE
4-List all files in directory. This disp1ays a list of all
files (data files and programs) in the directory. For each file,
the display provides the filename, file type, file size in sectors,
and the disk number on which the file resides. If a particular
filename exists on more than one disk, it will be listed the
appropriate number of times. This can be helpful in reducing
redundancy and, consequently, increasing available storage
space. It is helpful if the filenames have first been sorted
alphabetically. Figure 3 shows a typical screen display for this
option.
Figure 3: Files in Directory
NAME TYPE SIZE DISK
ARTICLES PROGRAM 30 11
ASSMI PROGRAM 33 3
ASSMI PROGRAM 33 7
ASSM2 PROGRAM 20 3
ASSM2 PROGRAM 20 7
BACHMUSIC PROGRAM 31 2
BARCHARTS PROGRAM 31 6
BARRICADE PROGRAM 30 10
PRESS ENTER TO CONTINUE
5-Search directory by disk #. This allows you to search
the directory file by disk number. It will generate a display
similar to Figure 3. However, the list will contain only those
files on the indicated disk number. This is useful for determin-
ing which files are on a particular disk.
6-Search directory by filename. This allows you to
search the directory file for a particular filename. It will dis-
play the disk number and name on which the requested file
293
Utilities ______
294
-
_ _ _ _ _ _ Uti.lities
295
Utilities _ _ _ _ __
296
_______ Utilities
298
- -_____ Utilities
--
43 30 DO~ =S EG~(F$(L), 1 5,2)
-. 4340 RE TURN
5000 Bosue 551210
50 03 C ALL CL EAR . . CALL SCREE N (S)
5005 X-Ill
5010 GOSUf( 51£113
5 01 5 IF O$(DN) = '''' THEN DI SP LA Y AT( 1 2~1} : " **
NO S UCH DISK # IN OI R . ** " : : GO TO 5 050
50 2 0 FOR L= l TO NF
5022 I F F$(L I= " " TH EN 5040
502 3 DW$ =RP TS(" " . 2 - LEN(STR'f(DN» )LSTR ~(DN )
50 2 4 I F D W$ <> SEG$(F $ (U.15 . 2) THEN 50413
5025 Gosue 4 300
50 30 DISPLAY AT(X * 2 + 7 , l':U S ING '.~######### #
•••••• ### (3 SPACES) •• ":N$ . TF$ ( AB 5 ( VAL(
T$» ) ,5$,0 0$
5035 X- X+l . . IF X-B THEN Gosue 5200
512140 NEXT L
5050 DISPLAY AT( 2 4, I) : "PRESS ENTER F OR MENU "
5060 CALL KEYe3,K , SI :: I F K <> l3. THEN 5060
511'1713 GO T D 500
5100 DI S PLAY AT(2,3): " ' . FI L E S ON DISK .": DN
;".*"
5 110 DI S PLA Y AT(4,1 ) : " N A ME{9 SP A CES}T'( PE 5 1
ZE DIS K"
5115 CALL HCHAR( 6 . 3 ,4 5 . 2S)
5 1 2121 RETURN
521210 X=0
5210 DI SP LAY AT (2 4 ,l): " PRE SS ENT ER TO CONT IN
UE"
5220 CALL KE Y (3 . K . S) :: IF K( } 1 3 THEN 52 20
52 3121 CALL CLEAR . . GOSUS 51 00
5240 RETURN
551210 CALL CLEAR .. CALL SCREEN(6)
55 10 DISPLAY AT ( 4, l ) :" SE AR CH DIRECT ORY BY OI
SK #"
5520 DISPLAY AT(B ,l ) : " ENTER DISK # . . AC
CEP T AT( S , 14 ) VALI DATEt NUM ERIC)S I ZE ( -
2 )BEEP:DN
5530 I F DN (0 1 OR DN} 50 THE N 552121
-- 5550 RETURN
600 £1 GOSU B 65121£1
6 0121 3 CALL CLEAR CAL L SCREE N lS)
6 01215 X=12I : : 5 W=0
6 01 0 GOSUB 6100
612120 FOR L= l TO NF
612122 IF F ~( L)="" THEN 6040
61212 4 IF SE G$(PW~ .l . LEN(P W $) (~ S EG$ (F $ ( L ) .l .L
ENtPWS»TH E N 6@ 4 @
299
Utilities ______•
300
______• Utilities
301
Utilities _ _ _ _ __
: SS~1
80'5121 NEXT L
8060 IF 55:::1 T HEN H F ~ =F ~ ( Y): : F ~ ( Y) = F~(HX)::
8070
8080
F~(HX )- HF$
Y_Y+ I :: F$(I2I):F$(Y)
IF Y< NF THEN 812125
-
812190 GOTO 5121 121
9121121121 CALL CLEAR :: C ALL SCRE EN ( B )
912110 DISPLAY AT(4. 1 ) :"THTS OPTION WILL WRITE
THE"
91212121 DI SPL AY AT<6.1):"DtRECTORY FIL E TO DISK
IT"
9 1213 121 DI S PLAY Al(B. 1 ) :"WILL OVERLAY ANY PREVI
DllS"
91214121 DISPLAY AT(10 . 1):»OIRECTORY FILE."
91215121 DI SP LAY AT(14~1):·WRITE PILE (YIN)?
:: ACCEPT AT(14~20)VALIDATE("YN·)5JZE(
- l )BEEP;O~
91216121 IF OS="N" THEN 5121121
91121121 OPEN . 2 :"DSK1.DI5KDATA" ,OU TPUT,INTERNAL
,F IXED 2121
911215 PRINT . 2: ND,NF
911e FOR L=1 TO ND
912121 PRINT * 2 :D S(L)
913121 NEXT L
9140 FOR L=I TO NF
915121 PRINT .2:FS(L)
9160 NEXT L
9180 DISPLAY AT(20, l):"UPDATE . COMPLETE" .. D
ISPLAY AT( 2 2, Il:"PRESS ANY KEY FOR MENU
9185 CLOSE * 2
919121 CALL KEY(3 , K.S):: IF S=12I THEN 9 19121
9199 GOTO 50121
1121121121121 CALL CLEAR :: CA LL S CREEN(6 )
11211211121 DISPLAY AT(8,1): .. PRINT IN G . . . . . "
112112115 OPEN M3 : " P I0. L F" ,O UTPUT
11211212121 GOSU8 12121 121121
11210 3121 FOR L=1 TO NF
11211214121 GOSU8 4 3121121
19959 PRINT . 3 ,U SI NG " {b SPACES} ••••••••••
{5 SPACES} ••• {S SPACE S} •••••••
{ 4 SPACES}**":N~,S$,TFS ( VAL(T$»,DD$
112112160 LC-LC+l .• IF LC=58 THEN GOS UB 11121121121
11211217121 NEXT L
112112175 CLOSE . 3
11211219121 GOTO 5121121
11121121 121 FOR X=LC TO 65 .. PRINT . 3 :" " . . NEXT
X
302
_ _ _ _ _ _ Utilities
303
A Beginner's Guide
to Typing In
Programs
What Is a Procram7
A computer cannot perfonn any task by itself. Like a car with-
out gas, a computer has potential, but without a program, it
isn't going anywhere. The programs publish ed in this book are
written in a computer language called BASIC. BASIC is easy
to learn and is built into the TI.
BASIC Procrams
Computers can he picky. Unlike the English language, which
is fu ll of ambiguities, BASIC usually has only one right way of
stating something. Every letter, character, or number is signifi-
cant. A COrnmon mistake is substituting a letter such as 0 for
the numeral 0, a lowercase 1 for the numeral 1, or an upper-
case B for the numeral 8. Also, you must enter all punctuation
such as colons and commas just as they appear in the book.
Spacing can be important. To be safe, type in the listings ex-
actly as they appear. Enter all programs with the ALPHA
LOCK on (in the down position). Release the ALPHA LOCK
to enter lowercase text.
Braces
The exception to this typing rule is when you see the braces,
such as pO SPACES} . This special situation occurs in PRINT
statements. For example,
ENERGY{IO SPACES}MANAGEMENT
means that ten spaces should be left between the words
ENERGY and MANAGEMENT. Do nol type in the braces or
the words 10 SPACES.
306
_ _ _ _ _ Appendh
307
Index
algorithms 41 characters, numeric codes and 19-20
AI Khuwari:tmi 41 redefining 49-54
alphabetical/linear sean::h 44 CHA RPAT subprogram 49
animation 201-7 "Chase, The" program 165-71
,mnuily fOffl1ula 103 C HRS function 20
arcrosine 31 CLEAR key 15
arcsine 30-31 command moclules 5
arTilYS 41-42 compound savings fonnula 102
arrow keys 11 "Computer Visuals" program 55-59
ASe function 20 COS function 29
ASCII character set 23-24 data base management 109
ASCII codes 9, 43-44, 49-50, 147, 211 , DATA statement 55
266, 271 defined functions 29-33
ATN function 29 DEF statement 29-33
base 16 199 d...... 30
" Basic Bubble Sort" program 38 DIM statement 41
" Basic Shell 5ort" program 38-39 disk controller 6, 291
" Basic Sort C" program 39 disk directory 291-95
" Basic Sort D" program 39-40 disk drives 6, 283- 303
binary search 45 Disk Manager Command Module 283
" Bowling Champ" program v, 179-85 DISPLAY AT statement (Extended
bubble sort 36 BASIC) 8
budgeting 77-78 " Duck Leader" program 150-57
CALL CHAR 20, 24, 49- 54. 197, 203-7, duration (sound) 226
21 1, 247-51 , 256, 266, 270-71 editing 14-17
CALL CHARrAT 254 ERASE key 15
CALL CLEAR 202-7, 271 Extended BAS IC 8, 9, 36, 56, 84, 109,
CA LL COINe 258-60, 270. 272, 273 158,20 1, 247,264,270,283
CALL COWR 56, 204-7, 25 1, 270 fantasy, in game programming 179
CALL DELSPRITE 257. 270, 271 FCTN key 14-1 5
CALL DISTANCE 255, 270, 273 features, of TI-99/ 4A computer 3-8
CALL GCHAR 147. 152, 202-5 " Financial Interest" program 99- 108
CALL HCHAR 19. 202-3 formulae
CALL JOYST 272 annuity 103
CALL KEY 12, 19, 24, 34- 35, 152 compound savings 102
CALL LOCATE 255, 265, 270, 272 loan payment 103
CALL MAGNIFY 252-53, 270-71 mortgage payment 103
CALL MOTION 251, 256-57, 270, 272 FOR-N EXT loop 152
CALL PATTERN 256, 270, 272 " Freeway 2000" program 158- 64
CALL POSITION 253-5 4, 270, 273 function key codes 22-23
CALL SCREEN 14 games, writing 9-13, 158
CALL SOUND 3-4, 226, 240 increasing speed of 165
CALL SPRITE 9. 251-52, 270, 271 graphics 3, 55-56, 197-200
CALL VCHAR 19. 202 graphics characters, user-definable 24- 25
cassette recorder 6, 109, 111-13 INPUT statement 21, 24, 35
character set 18-25
redefining 211-16
character table 202-3
308
interest, simple and compound 99-100 SIN function 29
INT function 10, 29 sorting 36-40
joysticks 11 - 13, 147, 158, 165 "Sound Maker" program 226-37
keys, functions of 14-16 "Sound Shaper" program v, 238-39
linear search 44 speech 5, 7, 158
linked list flIe access 127 speed, game design and 165
UNPUT statement 128 spreadsheets 84- 92
LIST command 16 "Sprite Demonstration" program 260-63
loan payment formula 103 "Sprite Editor" program v, 264-69
logarithms 30 sprites 8, 9, 158, 20 1, 247-79
we function 29 collisions 258-60
" Mailing Ust" program v, 65-74 defining 249-51 , 270- 72
" Marble" program 207- 10 displaying 251-52
" Master Disk Dir«tory" program magnifying 252-53
291-303 moving 255-58, 272
mazes 150 standard deviation 76-78
mean 75-78 "Statistics" program 78-83
MERGE (Extended BASIC) 8 strings 4
" MINI-DBMS" program 109-13, 115-20 "SuperFont Load Demo" program 225
" MINI-REPT" program 109, 113-14, "SuperFont" program v, 211-25
120-26 TAN function 29
modulo 33 telecommunications 7
mortgage payment formula 103 Terminal Emulator I Command Module 7
mortgage 100-101 Terminal Emulator II Command Module 7
moving objects 11 text 3
music 3 " Thinking Harder" modification of
naming variables 4-5 " Thinking" program 173
NUM command 5, 1 "Thinking" program v, 172-78
numeric codes 19-22 TI BASIC 4
OPEN statement 61 "Tleale" program 84-98
Panasonic RQ2309A cassette recorder 6 commands 90-91
" Passing Variables" program 53 hardware Tt>quirements 84-85
pattem-identifier 49-52, 197- 200,211 , missing values 89- 90
248 " TI Disk Deleter" program 283-90
peripheral box 7 TI Extended BASIC. See Extended BASIC
pitch (sound) 226 "TI Mozart" program 240-42
pixel 201, 264 TI RS-232 interface 7-8
portability 55 " TI Word Processor" program 127- 43
printers 60-62 hardware requirements 127
PRINT USING (Extended BASIC) 8 operation 128-32
radians 30 printing 132-33
RANDOMIZE command 1- 11 TMS9918 video display processor 201
random numbers 10-11 TM5S9900 chip 201
range 76 TRACE command 5
reality, game simulation of 179 tra nsferring va riables 49- 54
" Receiving Variables" program 54 "Trap" program 147- 49
RES command 5, 16-17 unbiased random umpJe 75
RND function 10 user's reference manualS, 211
rounding 31 variable data
RS-232 interface 60--61 storing 51-52
" Runway ISO" program 270--79 recovering 52
"Searching Algorithms" program 46--48 variables 41
searching data 41 - 48 volume (sound) 226
sexagesimal numbers 32 " Worm of Berner" program v, 186--94
shell sort 37
309
COMPUTE I Books
Ask your retailer for these COMPUTEI Books or order
directly from COMPUTEI .
Call toll free (in US) 800-334-0868 (in NC 919-275-
9809) or write COMPUTE! Books. P.O. Box 5406.
Greensboro. NC 27403.
--
_ _ COMPUTEI's First Book of 11 Games
_ _ COMPUTEl's Guide to Extended BASIC
Home Applications on the TI-Q9/4A
,~. TDtoI
$12.95 _ _
$12.95 _ _
_ _ Creating Arcade Gomes on the TI-99/4A $12.95 _ _
_ _ Programmer's Reference Guide to the TI-99/4A $14.95 _ _
_ _ TI Gomes for Kids $12.95 __
_ _ J.3 Programs for the TI-9Q/4A $12.95 __
__ COMPUTE!'s Guide to TI Sound & Graphics $12.95 __
__ COMPUTErs TI Collection, Volume 1 $12.95 __
__ BASIC Programs tOf Small Computers $12.95 __
__ Computing Together: A Parents & Teachers
Guide to Computing with Young Children $12.95 _ _
_ _ Personal Telecomputing $12.95 _ _
_ _ COMPUTEI's Guide to Adventure Games $12.95 _ _
'Add $2.00 pel book 'Of ~ and tlOOdIing.
OuIside us odd 55.00 '* moil Of S2 00 SlJ'foce moil
.A••
COMPUTE!'s
P.o. Sox 5406
~~.
Greensbofo, NC 27403
My computer is:
o Commodore 64 0 VIC-20 0 Other_ _ _ _ __