Access Key Details ||
Previous Page ||
Next Page
Book index page |
Stephen's Entry page
CHAPTER SEVEN
EXTENDED BASIC
The Extended Basic module is not inexpensive, and information
on what it can do is not widely available. Therefore this
section has been included to help you to decide if you need the
module, and to give some short hints on its use.
Extended Basic exists in two distinct versions, Vn 100 and Vn
110. Only a very small handful of the earlier Vn 100 have been
sold in the UK, and this book refers to Vn 110. A principal
difference is speed: 110 is much faster. There have also been
changes in the operating systems which sometimes cause
incompatability between the two versions (with special reference
to the sprite routines and user sub programs).
EXTENDED BASIC is a VERY much larger language than TI Basic.
The increase in operation speed is not shown by magazine 'bench
tests' which use very short specific programs. In a typical
program you will find the program runs in about 30% less time.
Line transfers and screen handling are particularly faster than
in TI Basic.
In itself, this is a great attraction, but Extended Basic
also adds very many new commands and functions, enabling better
use to be made of limited memory, and also permitting friendlier
programs to be written.
Many TI BASIC programs can be loaded in Extended Basic, and
will then run faster.
Exceptions are:
TI Basic programs over 12k cannot be loaded due to lack of
memory.
Some TI Basic programs will load but cannot RUN due to lack
of memory.
TI Basic has two extra character sets: if these are used,
they will produce a BAD VALUE error in Extended Basic.Extended
Basic uses the memory saved by dropping these sets (15 &16) to
produce the Sprites.
What is new? The following is only a short list:
ACCEPT AT and DISPLAY AT permit you to display text anywhere
on the screen, or to accept anywhere. There are numerous
variations to these commands:
Optional 'beep',the ability to input data already on the
screen or type over it,validation of input, and for the display
of data, the ability to 'image' numbers. This allows simple
justification of numbers.
Typical use: ACCEPT AT(6,12)BEEP VALIDATE("YN") SIZE(-1):A$
If there is a "Y" at row 6,column 12, just pressing ENTER
will place Y into A$. Press any key but Y or N and the input
will not be accepted, the computer returns to the line itself,
and waits for a valid input.
CALL: In addition to the subprograms provided (eg COLOR,
SOUND and so on) you may write your own sub programs, which you
activate with CALL - for example CALL MYSUBPROG.
As with the TI subprograms, you may pass values or variables to
your subprogram, and variables used in the subprogram are
separate to variables in your main program. This is potentially
a powerful programming capability.
Unfortunately the usual system error traps work badly with
user written sub programs, and if an error message is generated
it will usually be the wrong message for the error the computer
has discovered. You must be careful how you write your
subprogram!
A number of the built in CALLs have been extended, to allow
you to define 4 characters at once, or amend all the colors at
once- eg CALL COLOR(1,2,2,2,3,3,8,15,16) and so on.
This not only saves memory but also processes more quickly.
SPRITES you have probably heard of: they are smoothly moving
graphics characters, which move under the control of the Video
Display Processor, while your program carries on with other
things.
TI allow you 28 sprites, each of one to four characters. They
may also be double size (eg a 4 character sprite occupying the
screen area of 16 characters).
There are subprograms built in to determine if sprites are in
a particular position or overlapping, and you may quickly
reposition them, change velocity, change colour or change the
character of a sprite.
There are two restrictions which mean you need programming skill
to use them to full effect:
The processor can only handle 4 sprites at a time in line.
Each row of pixels is restricted to 4 sprites-any extra are made
invisible.(A PIXEL is one dot in a character grid. A TI99/4A
character is made up of dots in an 8 x 8 grid).
The CALL COINC coincidence checker only checks at the instant
that command is used: you need to use it fairly often if a
coincidence is not to be missed.
Nevertheless, in the hands of skilled (and patient)
programmers, sprites can produce some VERY clever programs (in
a form of the BASIC language too).
IF...THEN...ELSE has been greatly improved. You are no longer
limited to line transfers, but may use:
IF A=4 AND B=6 THEN R=10 ELSE PRINT "OOPS"
Using IF..THEN..ELSE with commands enables you to use the
memory available in a much better way.
LET
You do not actually use LET with the 99/4A, but it has to be
listed somewhere...
In Extended Basic, instead of using: A=0 B=0 and so on,
you may assign one value to several variables in a neat and
memory saving manner:
A,B,C,D,E,F,G=0 will reset all those variables to zero!
LINPUT: Ordinary INPUT removes leading spaces and causes
problems if you wish to input a string with a comma in it.
LINPUT avoids these problems. It stands for LINE INPUT.
LIST...when you LIST you may make the computer PAUSE in the
list by pressing any key, then press another key to make the
LIST continue.
ON BREAK NEXT disables the CLEAR key except when the computer
has halted for an INPUT or ACCEPT AT. By avoiding these input
commands you can make your program unbreakable..
ON ERROR is a VERY useful command. Normally an error causes
your program to break, but you may use this command to transfer
program execution to an error routine of your own. Your error
routine may end by instructing the computer to try the problem
line again, to go on to the next line, or to go to any other
line in the program. You may also print your own error messages,
such as "PRINTER NOT CONNECTED". This command can be used to
make your programs totally user friendly. NB:Do not insert until
your program is completely debugged!
ON WARNING is similar but with fewer options: you may halt
the program or continue.
PROGRAM LINES: May now contain more than one command, and can
be entered up to 5 screen lines long (but limited to 128 bytes
long internally).
You may use IN COMMAND MODE for instance:
FOR A=110 to 220 :: CALL SOUND(200,A,0) :: NEXT A
The double colon is a statement separator. In TI Basic you
could enter PRINT A::B::C.
In Extended Basic you must leave a space between the colons:
PRINT A: :B: :C
(A program in TI Basic is converted automatically by the
machine to the new format, but you must take care when typing in
a program. Due to an omission in the error handling system,
typing too many colons together in Extended Basic can cause the
processor to 'lock out')
When this is linked to the new capabilities of the IF...THEN
command, it is possible to put together some very powerful
program lines:
IF A=B THEN C=5 :: PRINT A :: ELSE IF A=8 AND B=C THEN GOTO
3400 ELSE CALL SOUND(100,110,0) :: GOTO 200
As the lines become longer and more complex, you do need to
take greater care, but the language gives you a very powerful
tool.
In addition to using REM after double colons, you may use a
'tail remark', which is a '!' as follows:
SCORE=0 ! RESET SCORE
RUN
It is possible to RUN one program from another:
RUN "CS1" or RUN "DSK1.PROGTWO"
SAVE: Programs may be saved in PROTECTED format, which
prevents listing, editing or saving, and may be saved to DISK
ONLY in Merge format, which allows program segments to be
spliced together.
SPEECH:
From the speech editor module comes CALL SAY and SALL SPGET,
which enable your Extended Basic program to use the speech
synthesiser.Although TI provide a vocabulary list with the
Extended Basic module, full instructions are not provided.
CALL SAY allows you to SAY a word from the vocabulary. Words
NOT in the list will be spelt. Some 'words' are really phrases,
but if you use CALL SAY("READY TO START"), the computer will
SPELL the words! This is because the space is treated as a word
separator. For the computer to recognise that these three words
are one unit in the vocabulary, you need to enclose them in hash
marks: CALL SAY("#READY TO START#")
The standard punctuation marks are also word separators and
provide differing degrees of pause between words.
In order of length of pause, the separators are:
+ (space) - , ; : .
The + is zero pause and the full stop is a one second pause.
The separators may be repeated to build up any pause,eg:
CALL SAY("I---KNOW") or CALL SAY("I-,,KNOW")
CALL SPGET is used to fill a string variable with the data
use by the speech synthesiser. This can increase the speed of
execution if you fill some string variables at the start of your
program, and then use them when you wish to speak. It takes a
little while to fill the variables, as each string is 255
characters long (many of them are nul or zero value).
eg CALL SPGET("WORKING",WK$)
then
CALL SAY(,WK$) will say the word.
Note the comma in front of WK$. If two strings are used,in
addition to the leading comma, they must be separated by TWO
commas: CALL SAY(,A$,,B$)
In addition, you may use SEG$ to curtail the string you have
returned. You can then separate the initial sounds of each word,
and use these to create your own vocabulary. You are NOT limited
to the preprogrammed list: you just have to work a little to
expand it.
For example, having loaded WK$ as above, try:
WK$=SEG$(WK$,1,60)
CALL SAY(,WK$)
Notice any change? Try using different lengths in the SEG$
command. This is an area for experimentation.
SIZE returns the amount of free memory.
EXTENDED BASIC uses some of the system RAM, and you do not
have quite as much memory available for your programs. In
addition, the cassette loader cannot handle programs over 12k.
The good news is that with Extended Basic you may access the
memory expansion unit, which permits you to load (from DISK) a
program up to 24k, and still have some 14k available for
variables and so on.
The new function key REDO will repeat your last entry, and if
the last entry was a program line (either just entered, or
recalled using FCTN X) the line reappears on the screen with the
cursor at the beginning of the line NUMBER, allowing you to
change the line number if you wish. This function is useful if
your program contains a lot of lines either the same or with
only small differences.
That was a brief summary only of the attractions of EXTENDED
BASIC. It does require a little more care in use, but gives you
considerably more programming power.
An added attraction of the module is that it permits you to
load and run Assembly language programs, provided you have the
extra peripherals required.
Example: In the USA, TI release TI INVADERS on disk for half
the price of the module. You require a disk system and the 32k
memory expansion.
A utility package is sold in the USA on tape which requires
the 32k RAM and permits fast pseudo-high resolution graphics, or
the rapid dumping of the screen to a printer(RS232 card required
for the latter) or to disk(disk system required).
============================================
Lockouts have been found to occur in the present Extended
Basic by using CALL PEEK at one particular section of memory
(the addresses vary from console to console), and by using a
number of print separators without spaces:
PRINT ::::::: (Correct in TI BASIC, but Extended Basic
requires a space between each colon).
-----------------------------------------------
The following program has been included to show how SPRITES are
used in EXTENDED BASIC.
The program was developed in a highly experimental manner, as
various routines and values were tried.
To obtain the best from SPRITES it is usually necessary to work
in this manner.
NB- If your printer prints pound signs in the program listing,
it REALLY means HASH, which is CHR35 , coincidentally, this is
SHIFT 3 when using TI Basic or Extended Basic in TI Emulator.
100 REM SPEEDRACE
110 REM A SAMPLE PROGRAM IN
120 REM TI EXTENDED BASIC
130 REM USING SPRITES
140 REM
150 REM ===================
160 REM
170 CALL CLEAR
180 PRINT "SPEEDRACE":"COPYRIGHT 1981":"BY STEPHEN SHAW"
190 PRINT "USE S & D TO MOVE ":"LEFT & RIGHT":" ":"USE KEYS 1,
2,3,&4 TO":"SELECT GEAR"
200 PRINT "DISTANCE & TIME ARE ":"DISPLAYED.":"DISTANCE
SUFFERS IF YOU":"CRASH"
210 PRINT "PRESS ANY KEY TO CONTINUE"
220 CALL KEY(3,V,M)
230 IF M<1 THEN 220
240 CALL SCREEN(2)
250 FOR X=1 TO 100 :: NEXT X
260 CALL CLEAR
270 CALL MAGNIFY(3)
280 M=1
290 X$=RPT$("0",40)
300 CALL CHAR(100,"96FEBA3838BAFEBA"&X$)
310 CALL CHAR(108,"5A5A5A5A5A5A5A5A5A5A"&X$)
320 CALL CHAR(104,"FF1111FF0000FF11FF"&X$)
330 CALL SCREEN(4)
340 CALL SPRITE(#6,108,13,80,9,90,0)
350 CALL SPRITE(#7,104,13,75,25,90,0)
360 CALL SPRITE(#8,104,13,70,38,90,0)
370 CALL SPRITE(#9,108,13,65,9,90,0)
380 CALL SPRITE(#10,104,13,60,25,90,0)
390 CALL SPRITE(#11,104,13,55,38,90,0)
400 CALL SPRITE(#12,104,13,50,9,90,0)
410 CALL SPRITE(#13,104,13,45,25,90,0)
420 CALL SPRITE(#14,104,13,40,38,90,0)
430 CALL SPRITE(#15,104,13,85,139,90,0)
440 CALL SPRITE(#16,104,13,80,150,90,0)
450 CALL SPRITE(#17,108,13,75,170,90,0)
460 CALL SPRITE(#18,104,13,70,139,90,0)
470 CALL SPRITE(#19,104,13,65,150,90,0)
480 CALL SPRITE(#20,104,13,60,170,90,0)
490 CALL SPRITE(#21,104,13,55,139,90,0)
500 CALL SPRITE(#22,104,13,50,150,90,0)
510 CALL COLOR(8,3,4)
520 CALL SPRITE(#23,108,13,45,170,90,0)
530 CALL VCHAR(1,8,140,216)
540 CALL COLOR(14,12,12)
550 CALL VCHAR(1,7,95,24):: CALL VCHAR(1,17,95,24):: CALL
CHAR(95,"5555555555555555")
560 FOR CT=1 TO 4
570 CALL SPRITE(#CT,100,CT+6,CT*47-45,93-CT*8,0,0)
580 NEXT CT
590 CALL SPRITE(#5,100,16,160,74,0,0)
600 REM **
610 REM ***
620 CALL SOUND(-1000,-2,30-7*SPEED)
630 CALL COINC(ALL,D):: IF D<0 THEN GOSUB 780
640 CALL KEY(0,A,B):: IF A=ASC("S")THEN CALL MOTION(#5,0,-10)
650 IF A=ASC("D")THEN CALL MOTION(#5,0,10)
660 IF A<30 THEN CALL MOTION(#5,0,0)
670 CALL COINC(ALL,D):: IF D<0 THEN GOSUB 780
680 IF A>48 AND A<53 THEN SPEED=(A-48)/3
690 CALL COINC(ALL,D):: IF D<0 THEN GOTO 760
700 T=T+1 :: S=S+6*SPEED :: DISPLAY AT(10,18)SIZE(10):STR$
(S)&" "&STR$(T)
710 CALL COINC(ALL,D):: IF D<0 THEN GOTO 760
720 IF T/5=INT(T/5)THEN M=-M
730 CALL MOTION(#1,SPEED*40,M*5,#2,SPEED*40,M*5,#3,
SPEED*40,M*5,#4, SPEED*40,M*5)
740 CALL COINC(ALL,D):: IF D<0 THEN GOSUB 780
750 GOTO 620
760 GOSUB 780
770 GOTO 620
780 CALL SOUND(-900,-6,0)
790 CALL MOTION(#1,0,0,#2,0,0,#3,0,0,#4,0,0,#5,0,0)
800 SPEED=1/3
810 S=S-50
820 IF S<0 THEN S=0
830 CRASH=CRASH+1
840 IF CRASH=15 OR T>200 THEN GOTO 920
850 M=+1
860 T=T-(5*(T/5-INT(T/5)))
870 FOR CT=1 TO 4
880 CALL SPRITE(#CT,100,CT+6,CT*47-45,93-CT*8,0,0)
890 NEXT CT
900 SPEED=0
910 RETURN
920 CALL CLEAR
930 PRINT "YOU HAVE TRAVELLED ":"A DISTANCE OF ";S
940 PRINT "AND HAD ";CRASH;" CRASHES!"
950 IF S>500 THEN PRINT "YOU ARE NOT A BAD DRIVER"
960 IF S<100 THEN PRINT "YOU SHOULD NOT BE ON THE":"ROAD"
970 PRINT "TO TRY AGAIN,ENTER 'RUN'"
980 END
Note especially the number of CALL COINCs which have been used.
Even with this number, some crashes will still go undetected.
THE INFORMATION IN THIS BOOK IS FREE. It may be copied, distributed and/or modified under the conditions set down in the Design Science License published by Michael Stutz at http://dsl.org/copyleft/dsl.txt
Book index page |
Stephen's Entry page
Access Key Details
Stephen's Entry Page |
TI99/4a |Linux |Search |
History St Thomas Church Heaton Chapel |
Entertainment | Music Links
Light Reference | Educational Reference | Science Fiction |
Travel | News Links | Anime