[ Go to Stephen's Entry Page ]
[ TI99/4a Articles index |    TI Book front page |    TI Resources Page |   PC99 Programs    | TI*MES 7    |   TI*MES 8 ]
contact - please use subject="pc99 page" to avoid spam trap!

Jump to:
TI Forth section including Forth sounds, speech, faster trig, returning to title screen, formatting a floppy.
Basic: A use for the POS function
Basic: Location of DATA statements
Basic: Faster trig functions TAN, SIN, COS
Extended Basic: Prescan !@P-
Disk Not Initialised- repair
Basic: Extra CALLS with Personal Record Keeping module
Disks and Fractured files
Review Smart Programmer   ||   Review Super 99 Monthly ||    Review Tigercub Nuts and Bolts
News from Stainless Software

This web page contains the text of my articles for owners of the TI-99/4a in a series called Rambles, from Issue 10 of TI*MES dated Autumn 1985, published by Clive Scally. It is of use to users of the TI-99/4a emulators and of historic interest regarding home computer use in the UK in 1985.

Rambles from TI*MES Issue 10, Autumn 1985

Other material from the magazine (Rambles follows) :-

From Clive Scally:

In this issue we give news of the third Show. Yes it is in the heart of Britain. BIRMINGHAM often hosts the best shows and this one will be no exception for TI99/4a enthusiasts. Those of you who have supported previous shows will know that it is good to get together and get to meet other TI users.

You will meet and talk to many of the group writers. See some of the latest things happening to the TI console in the way of hardware and software available from the two 100 per cent TI dealers. Of course many books will be on sale too. You can really get a lot of comfort that there is a lot going for the TI99ers.

You are invited to join in the fun of the day, if you wish to help at the show then drop in at the Group stand. Everyone will pick up a bargain for Christmas, or sell that unwanted cartridge etc in the grand TI99 auction. There is a chance to win a valuable prize in the TI*MES draw. The TI OXON club will be there with PETER BROOKS who will show you a trick or two as you get to master the TI99. At the last show we were sorry not to have STEPHEN SHAW. this time he will be there to get you started.

(Comment- the previous show was in Brighton, about as far South as you can get, and held on a Sunday when public transport is restricted. I stood no chance of getting there and back without spending more time than I had available and much more money than I had available.sjs)

The Civic Hall, Digbeth is not far from the main rail station, the National coach station is on the doorstep. If you come by car vou will be amazed at the ease of the drive to the city. Your support will ensure that these shows continue, so come along and reallv make it vour day.

Go to top of page

Basic with PRK or PRG Modules From Graham Baldwin

In the last issue I mentioned Enhanced BASIC in passing, and the fact that it can be obtained from the Personal Record Keeping and Statistics modules.

Looking back through previous issues of TI*MES, this somewhat obscure subject doesn't seem to have been mentioned often, so, prompted by one or two enquiries about it, here goes.

When a PRK or Stats module is in the cartridge slot the normal menu appears after the title screen, ie. 'Press 1 for TI BASIC, 2 For Personal Records'.

On pressing '1' we obviously get TI BASIC, BUT with some additional sub-programs, prefixed with CALL, as usual, that give us Enhanced BASIC. These sub-programs enable us to set up PRK type-files from TI BASIC, giving somewhat more flexibility (and a great many more headaches) in programming and use than 'pure' PRK files allow, albeit with some restrictions.

The first sub-program I'm going to look at, and probably the easiest to get to grips with, is CALL D, the 'D' standing for DISPLAY. Yes, like Extended BASIC, we can actually display information anywhere on the screen (well, almost anywhere) without using the TI BASIC 'print at' simulation!

The syntax of CALL D is as follows:-
CALL D(ROW,COL,WIDTH,STRING/NUMERIC)
ROW is obviously the screen row, with a value of 1 to 24, top to bottom.
COL is the column value, from 1 to 28.
WIDTH (or size) is the field width of the information to be displayed, to a maximum of 28 characters. A positive value clears the row before the information is displayed; a negative value does not. (This should sound familiar to Ex BAS users, with their SIZE clause.) Although the width is limited to 28 characters (don't bother specifying anything greater; you won't get it), we can still get more than one line on the screen, again like Ex BAS, by putting more information into one CALL, following on with another ROW, COL etc. after the STRING/NUMERIC item.
STRING/NUMERIC is the information to be displayed, and can take the form of a string or numeric constant, variable or expression.

The next CALL to look at is CALL A, or ACCEPT. We are no longer tied to an INPUT at the bottom of the screen, where we don't always want it; again, like Ex BAS ACCEPT AT, we can take information from anywhere on the printable part of the screen. This is the syntax:-
CALL A(ROW,COL,WIDTH,RETCODE,RETV)
ROW, COL and WIDTH are as for CALL D
RETCODE is a variable that is given a value according to which key has been used to enter information. (No, we don't have to use ENTER.) The codes returned are as follows:-
1. ENTER was used.
2. A null was entered
3. FCTN 7 was used.
4. FCTN 8 was used.
5. FCTN 6 was used.
6. FCTN 5 was used.
7. FCTN 9 was used.

FCTNs 5 to 9 are the BEGIN, AID etc. keys, the use of which can make a program more user-friendly, and when used with CALL A, save us a CALL KEY routine to find which key the user pressed.
RETV is the return variable that will contain the string or numeric data from the keyboard.

There are some optional extras that will fit into the brackets, the first of which is a Field Number, used when setting up PRK-type records in Enhanced BASIC, a subject I propose to tip-toe away from for now. The second is a maximum and minimum value range check of numeric information entered, taking the form ...L0,HI) after RETV.

By the way, you can't break (FCTN 4) out of CALL A...

There are several more CALLS, the details of which are increasingly obscure and I don't have the time or space to do them justice for the moment. TI used to publish an information sheet about them, and the official TI document is available online - a booklet in pdf format from whtech.com- that gives some more gen on the extra CALLs.

Go to top of page


Using the POS function with input

Here's a short routine to extract a month number, 1 to 12, when the first three letters of any month are entered. It uses POS, a dazzlingly fast device for this sort of job. Try writing the routine in a different way, without using POS, and ponder the speed difference.

100 INPUT "MONTH?":M$
110 M=(POS("JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC",M$,1)+2)/3
120 IF M<>INT(M) THEN 100
130 PRINT "MONTH NUMBER IS ";M

Extended Basic pre-scan
About the most obscure Ex BAS facility must be the pre-scan selectors, !@P+ and !@P-. These don't even find their way into the Ex BAS manual but appear in a seperate leaflet, entitled "Important Product Information for TI Extended BASIC" (pdf file from whtech.com), usually, but apparently not always, supplied with the module.

When a program is RUN it is scanned to reserve space for variables, arrays, DATA etc., which all takes time, hence the delay before a program begins to execute. By including the pre-scan 'on' and 'off' statements at judicious points in the program we can prevent the computer wasting its time (and ours) looking at lines containing variables etc. that already have space reserved, and thus get our program running a little quicker.

By the way, pre-scan 'on' is !@P+ and 'off' is !@P-.

An oddity of !@P- is its ability to dump us back into TI BASIC if certain types of error are found on pre-scan, which could be useful in some circumstances, otherwise make sure ALL errors are cleared from the program before using it...

Variable Names
Red herring department again. All variables must start with or consist of a letter, right? Of course - er, hang on. Some non-alpha symbols can be used if you so wish ('@' is one of them). No doubt there's some inscrutable TI logic behind it somewhere...



Rambles by Stephen Shaw
OK... gossip first as usual, serious stuff later... STAINLESS SOFTWARE .... will be closing down at the end of October l985, due to lack of interest, as losses now reach towards four digits .... a few programs will be placed into the User Club libraries, but most will merely cease to be (legally) available. Note that in such cases copyright will continue to apply. If you need anything in the Stainless catalogue, please do not delay!

I shall however continue to maintain a library of public domain/freeware programs available to club members at low low prices. SAE for details please. Contributions of both funds and programs are most welcome: but nothing which is copyright please!

PUBLIC DOMAIN: I understand that there is some misunderstanding about this term. In U.K. law, EVERY artistic creation is AUTOMTICALLY copyright : everything created in the U.K. IS COPYRIGHT. In the UK, the closest we can come is OPEN LICENCE where an author, although retaining copyright, authorises anyone to copy his work. He may if he wishes make the consent subject to certain restrictions (eg the work is not sold commercially, or with his name removed.

Similarly, in the USA, the FREEWARE range falls into this category of Open Licence, with the author retaining copyright, and some measure of control. There are a nuober of programs circulating which are NOT Public Domain nor Open Licence. Please be aware that copying a copyright program is unlawful even if you do not INTEND to deprive the author of his royalties. If you DO have such an intention ....

It has also come to my notice that some TI owners are merrily copying recent commercial copyright works, such as GRAPHX and INFOCOM adventures. This is not merely unlawful, it is insane: how much longer will authors bring out high quality material if xxxxs like that copy their work without paying a penny for it? If you should happen to have a hot for even slightly warm) copy of such programs, please give consideration to purchasing an authentic copy (and thereby supporting the commercial infrastructure which is also still necessary) or at the very least, sending the author direct an anonyoous donation for his work.

Is there anyone out there who still does not know what copyright is?

Go to top of page

Smart Programmer I have sent some cash on to Craig Miller, and now have the June, July and August 1984 issues of the SMART PROGRAMMER. September l984 has not yet been published (is this a record) although I understand the intention is to ultimately publish the l2 issues promised, and then HALT! with an occaisional (say quarterly) newsheet available thereafter.

NOTE: These three magazines are available online in pdf format from whtech.com - each file is just over a megabyte in size. The files are sp8406, sp8407 and sp8408.

The June SP has considerable console maintenance information, a map of GROM 0 (the GROMs have been rewritten several times! Craig maps those from an early 1983 console), and an Italian program to change machine code to CALL LOAD stateaents for XB, and a Forth program to copy disks in 3 passes using one drive only.

The July SP announces the ADVANCED DIAGNOSTIC program from Millers Graphics for US$20, which checks all memory, including 32k, and has a useful disk utility including a visual indication of disk drive speed. NB: the program is supplied on a disk which is almost impossible to copy.
Also in the July SP are maps for GROM 1 and GROM 2.
The Forth program is a general DSR utility.

And in the August SP
an excellent ISR driven machine code program to run with Extended Basic, which places a digital clock at screen top right, even while you are programming. I've used it for a Speaking Clock program, accurate to about 6 minutes per day, tells the time every 10 seconds, a DSR memory map of the TI RS232 card, some general assembly language print routines which use BLMP, and fifteen screens of Forth program for music (Star Trek theme over 6 screens).

Super 99 Monthly During the past quarter, I have received an excellent TI related magazine, called SUPER 99 MONTHLY. Only 16 pages, but good enough for me to send for all the back issues. At the time of writing the last issue I have is Issue ll, dated July 1985.

NOTE: Copies of Super 99 are available online from whtech.com in pdf format. Issue One is September 1984, Issue ten is June 1985.
A brief summary-
Issue: Summary:
1. General disk loader. Use of ERASE ALL. Transliterate. RES. Tombstone City.
2. Game. Merge. Forth ACCEPT AT.
3. Days between dates. Forth Phone list! Multiplan RPI. Stats.
4. Sound echo. Loading XB lowmem with m/c. LOGO music.
5. Solitaire Checkers Gane. XB Mouse. Speech Test. TIW XB. LOGO pattern.
6. Adding a keypad. REDO. M/c sector addressing. TIW hint.
7. 28 col prog lister. Multiplan exanple. M/c equates.
8. Joystick adapter. A routine to extract a part of an existing program.
9. Graphics on TI Writer. Number base conversion. Multiplan SYLK files.
10.Echoing PRINT with TE2 speech. MULTIPLAN SYLK files.
11.Review of COMPANION. PEB technical detail. Latest from Myarc.

Excellent value...
SUPER 99 MONTHLY, Bytster Cuter Services, 1 1 Husg Street, Su hur, LA, USA, J663.

Super 99 is 16 pages thick, has no ads, and prints original material. It is also a commercial, copyright, publication.

Note: I printed a TI99/4a screen dump together with the text in TI*MES, all in one pass on the FX80 printer, printing with TI Writer using the Formatter. Some folks thought TI Writer was a text editor and could not print graphics. Here is the comment I added:
The screen dump was produced using a program in SUPER 99 MONTHLY. If you would like to have this power, the issues to inspect (online - see above) are:
May 1985 ( Volume 1 Issue 9)
and June 1985 ( Volume 1 Issue 10)

Go to top of page

The July copy of LA99ers Toplcs tells us about the TI99/9 from dealer TexComp... which turned out to be a genuine TI99/4A inside an IBM PC casing. I understand that TexComp are not everyones friends ....
FORTH: No requests for more Forth but a request for less
After this no nore Forth unless ye asks for it lads!

It says my disk is NOT INITIALISED SLIPPED DISKS .... (Disk repair)
Your most valuable data disk suddenly won't load, and when you try to look at it with Disk Manager, back comes the answer DISK NOT INITIALISED.

(NOTE: This can happen with Windows machines so keep reading for a different Windows solution).

You have ignored all the good advice given you to always keep back up copies of valuable material. What do you do?

After wiping the blood off the wall, and retrieving your console from the garden ....

The Disk Manager module will tell you a disk has becone uninitialised when Sector 0 has been corrupted or damaged... and with a bad sector zero the disk is no longer available to your system. Or is it?

The disk system is either remarkably silly or very clever, depending on which way you look at it... as you can very easily recover a disk damaged in this manner.

((Windows users: If Windows thinks a floppy isn't readable, it helpfully makes sure of it by overwriting Sector 0. In virtually the same manner as with a TI disk partial recovery is possible in the same manner- but you need to take a healthy PC disk of the same size (720k, 1.44M or whatever) and copy the healthy sector 0 onto the "bad" disk. Chances are you will then be able to copy SOME (possibly all) of the disk content instead of losing it all. Copying Sector 0 is easiest with Linux of course. Or copy all of the bad disk except sector 0 onto a blank initialised disk using sector copying -NOT file copy)) TI disks again:
IF Sector Zero is merely corrupted but physically undamaged, go on to Step B below, but
if Sector Zero has been physically damaged and is incapable of being recorded on, start with step A. (How do you find out? Try Step B: if it doesn't work come back to Step A!).

STEP A: Take a blank initiallised disk, and using a sector copy utility copy all the sectors EXCEPT SECTOR 0 from the damaged disk on to the new disk. The new disk should have been initiallised with DISK MANAGER and have a valid disk name! Now go to Step C...

STEP B: Take ANY valid disk initiallised with Disk Manager... it does not matter if it has programs on it or not! Copy Sector 0 from the valid disk onto your corrupted disk. Now go to Step C...

Step C: You now have a disk which enables you to access and catalogue the files on it, but it reports an incorrect total nunber of sectors used/free.
Let's make the system put this right! Use disk manager module to make a back up disk of the 'incorrect' disk, and the backup will magically have the right details. Now junk the original disk you had problens with, and make a security back up of the repair!

Go to top of page

TI BASIC EFFICIENCY...
Some detailed benchmark timings in PCW July 85 led me to take another, closer look at the workings of our machine...
FOR...NEXT loopings are faster on the TI than on the Spectrum ....
A(4,5)=B(6,7) is faster on the TI than on the Commodore 64
X=5^2 is faster on the TI than on the Spectrum, the Commodore 64 or the Apple 2. In fact, Extended Basic is ten times faster than the Spectrum
CALL CLEAR is faster on the TI than on the Spectrum or Commodore 64.
Forgive me for not listing all the itens for which the TI is slower...
Conparing TI Basic with Extended Basic, in a short benchtest program it appears that XB is slower, but XB is much faster than TI Basic for such things as SQR, ^, ABS, LOG and SIN. ExBas string operations are faster... a simple A$="A" running three times faster in XB.

Where does DATA belong?
I also took a look at the use of DATA in programs, to try to settle the old chestnut of WHERE in a progran DATA should go...
As you might expect the answer is not so simple. It depends on whether or not your program uses RESTORE.
With DATA at the start of your program, RESTORE is faster but READ is slower, while conversely if your DATA is at the end of your program, RESTORE slows down a lot but READ is much faster. NB: this MAY differ on consoles with differing operating systems.

On average, how many RESTORES do you process, and how many READs?
If the nunber of RESTOREs TIMES FIVE exceeds the number of READs, place your data at the beginning. If the number of reads is more than five tines the number of RESTOREs, place the data at the end. The difference in the timing of RESTORE in a l0k progran is unbeleivahle!


TIW Formatter : Do you wish to prevent the FORM FEED at the END of printing? Make the last line of your letter etc: .PL 1 and the form feed is suppressed! NB: Do not forget to reset PL if you have another document to print!
(Thanks SUPER 99 MONTHLY for that excellent tip)

REVIEW: TIGERCUB DISK: NUTS AND BOLTS:
NOTE: Nuts and Bolts disks are available online from whtech.com in PC99 format, easily converted to MESS / v9t9 format with TI-dir.

Wow. 100 utilities!!! (well, one or two tips and demos in there... but still). You know that CALL CHARSET leaves the lower case letters with their space invader definitions! Jim has provided us with CALL CHARSET2... and several typefaces to choose from as well. There are so many useful utilities on this disk it is impossible to do a full and proper review in less than ten pages (it's DK Clive I'm not going to!). Very well worth the US$20 Jim is asking, and you will be supporting one of the User Groups most helpful supporters in so doing. If you use XB, and have a disk system, buy this disk.

Earlier I mentioned piracy of a program called GRAPHX. This program is Australian and is sold by Parco
Now... GRAPHX is a hi-resolution sketching program. There now seem to be lots of them about... but GRAPHX does stand out above the rest, with a superb manual (14meg zip from whtech.com), and 120% for ease of use.
It has help to assist with the odd VDP restrictions (which every other program ignores!) and of course the obligatory disk and printer saves. Parts of the picture can be saved or moved, and there is even a form of animation capability! The manual includes technical information for machine code programmers to enable them to use GRAPHX files in their own programs. Very highly recommended. If you buy just one sketching program, buy this one.

DRAW A BIT is an older hi res program, and comes in two versions, DAB1 and DAB2. DAB2 is more advanced but unfinished and of course harder to use. The manual supplied is a trifle ropey, and together with the appalling demo screens very nearly put me off progressing with the programs .... which would have been a pity. The two programs are quite different and each has its strong point. Ease of use is not too good, especially with DAB2! but with practice you can quickly come to grips with them.

How to compare these three hi res programs? GRAPHX scores highly on manual, demos, and ease of use. DAB gave me problems with PRINTING- I was able to amend DAB1 to work with my Epson FX8O, but still cannot print with DAB2.
DAB allows storage of actual drawing sequences, as well as storage of finished pictures, which can have its uses. DAB2 uses an automatic fill routine, which can be messy if there is a break in the outline, but both DAB1 and GRAPHX go for a semi-automatic FILL so the damage is contained!
DAB2 has many more features than GRAPHX including texture painting and more flexible addition of text to pictures, but lacks the ability to slide parts of the picture around.
DAB is cheaper! and is sold by Arcade Hardware. A serious graphics artist would need all three programs, because of the different effects each offers. And be advised: in hi res mode, the TI is capable of some astonishing pictures.

And do not forget SUPER SKETCH (and printer utility DFX Screen Dump)- Super Sketch may offer fewer utilities, but is handy for the younger sketcher or for a quick free hand sketch.

Dab is written by Dominic Melfi ....
Also by Dominic Melfi (and from Arcade) is a THREE GAME DISK containing KIPPY's NIGHTMARE , SPACE STATION 1 and BANG BANG SUB.
The latter puts you in command of a submarine being attacked by air and by sea. In all three programs the level of difficulty gets harder and harder and harder .... and in this package (twenty quid for three machine code programs!) do offer super value for money. All three games are quite playable - although they will be preferred by speed freaks! And I defy ANYONE to score over 300,000 on any of the games!

Oldtimers may recall CHRISTINE COMPUTING LTD., operated by Ian and Christine Godman down in Watford. Congratulations to the couple on the birth of BARBARA ANN at 4.50am!


Go to top of page

A discount mail order price list for TI99/4A software has fallen into my hands, from RAMTOPS, Levenshulme, Manchester. The catalogue has a large number of titles for the TI99/4A... looking very much like a list of titles from an old Stainless Software catalogue...
At no time has Stainless Software sold goods to this establishment, and our spy calling in the shop found no stock available. If anybody has sent money and had nothing back, please contact the Official Receivers Office in Manchester. A receiving order was made against Mr D Barrett trading as RAMTOPS on 18th July 1985, under reference MANCHESTER 25 of 1985.


Fractured Files And this is an excellent place to discuss EFFICIENT use of your TI disk system... although the TI does use its disks quite efficiently, knowing what it does can help you to obtain the best from it.

When you place a program (say) onto the disk, the controller looks at the disk index for unused space, and places your program there, marking the index accordingly. Although the disk manager will show you your files in alphabetical order, they actually occur on the disk in the order they are recorded .... assuming a blank disk to start that is.

Suppose you have a long file called XXX which you replace with a shorter file, also called XXX? The new recording will go over the old XXX and the space saved will be MARKED as available ( actually the data is still on the disk!). Subsequently you save a very long file YYY. Part of YYY may be placed in the 'saved' space no longer needed for XXX, and another part of the file may be found after file ZZZ... we then refer to file YYY as a FRACTURED FILE.

The disk controller looks at the index, deals with the first part of the file, and then moves the drive head to the next part of the file. This movement can be thought of as wasted time: it is faster and more efficient if files are NOT fractured.

Now take another disk with files A, B and C, recorded in that order. We wish to amend File A, making it longer... the extra will be placed after File C, and File A will again be fractured.

SO .... how to put files together? When you use the DISK MANAGER to copy a disk using BACKUP DISK and copy to a blank disk, the module/controller will record the new disk with entire (unfractured) files, placed on the disk in alphabetical order.

Efficiency hint number one: Fractured files are best healed!

You have noted that when copying files with BACKUP DISK the files are placed onto the new disk in alphabetical order?

This may not be the best thing for us!!! Suppose our disk has a LOAD file which is used frequently? The best place for a file used often is at the beginning of the disk, while rarely used files are best at the end of the disk. We can place files just where we want them by taking a blank disk, and using COPY FILE to place them onto the copy disk in the order we want.

As an example, let's look at MULTIPLAN .... when working with Multiplan, the system makes frequent reference to the file called OVERLAY, while files MPCHAR, MPDATA, MPINTR and MPBASE are used only when you start using Multiplan.
Your disk system can use Multiplan more effectively then if the files are copied in the order OVERLAY, MPHLP, MPCHAR, MPDATA, MPINTR and MPBASE.

Efficiency Hint Number Two: Files are stored on a disk in the order recorded: the further the files are from the disk directory the longer the 'head seek' times.
If you use any of the SECTOR COPIERS now available (including TI Forth) the copy disk will be identical to the master: fractured files will NOT be repaired... but if you have manipulated file order, that order will be retained.

Fast Trig Faster processing of SIN and COS functions:

Programmers who are trying to obtain hi res graphics on the TI often make very heavy use of SIN and COS.

Programmers in Forth and Machine Code have been disturbed to find that their programs are still pretty slow... ...

Now look at these two TI BASIC programs:
100 REM
110 PRINT "*********"
120 RAD=1.50
130 FOR T=1 TO 1000
138 R=RAD*1000
140 P=(((R*R*R/1E6)*(R*R*76/1E7-166))+1000*R)/1000000
150 NEXT T
160 PRINT P


100 REM
110 PRINT "********"
120 RAD=1.50
130 FOR T=1 TO 1000
138 REM BLANK
140 P=SIN(RAD)
150 NEXT T
160 PRINT P

These listings are calculating a SIN value 1000 times.

WHICH program ran fastest? And how did the results compare?
That awful TI BASIC program on the left gave an answer of 0.9974625 and took sixty six seconds to run.

The shorter program on the right gave a more accurate answer of 0.9974949 but it took one hundred and twenty five seconds!!!

Running the program on the right in Extended Basic took 75 seconds. but by changing line 140 to: 140 R=RAD*1000 :: P=(((R*R*R/1E6)*(R*R*R/1E7-166))+1000*R)/1000000 the time was reduced to 56 seconds.
So instead of using the built in SIN function, try using the right hand format with the modified calculation. Reducing time for 1000 sin calculations from 75 to 56 seconds is meaningful.

The long calculation in line 140 is only accurate from 0 to 1.7 radians. when the error is less than 0.7 per cent, perfectly adequate for screen graphics.

If you think the limitation to about 97 degrees is a problem, please remember the shape of a sine wave. It is possible to use this equation for all angles by splitting them up into the four quadrants and doing a little manipulation with the answer.
eg the SIN of 80 degrees is the SAME as the SIN of 100 degrees.
In one case (90-10) and in the other (90+10).
Similarly, the sin of (90+180+10) and (90+180-10) have an identical value but with a negative sign..

UPDATE from Issue 12- even faster.

Go to top of page

TI FORTH Jump to: Forth Call Sound with one voice || Forth Call Sound with one or three voices
Speech in TI Forth || Faster Forth Trig
Forth disk formatting || Forth resident words || Editing forth screens tip

A Forth question which I have received more than once... HOW do you return to the title screen, as QUIT does not work?
If you have loaded -SYNONYMS (or either Editor or any Graphics mode or -FLOAT) then you have access to the Forth word MON. To return to the main TI screen just type in MON and press ENTER.

To enter new Forth screens, select a bunch of unused Forth screens, lets say the first is Screen N. Type N CLEAR then N EDIT and enter the printed text, use BACK and FLUSH. The two screens of CALL SOUND(3 voices) below are quite separate from the one screen CALL SOUND for one voice.

Unhappy with default colours for FORTH text screen? They are set in line 9 of Screen 51. The value OF4 is white on blue.

Now down to business ....

Forth Sound FORTH CALL SOUND:
a. ONE VOICE ONLY.

Screen:

0 ( CALL SOUND ROUTINE FOR ONE VOICE APRIL 85 SJS )
1 ( USES VDP AREA 14336 TO 14345 )
2 ( duration in ms. volume 0-30, frequency CALLSOUND --- )
3 : SINIT -31747 C@ 1 OR -31747 C! 3 14336 VSBW ;
4 : FREQ S->F >F 111860.8 FSWAP F/ F->S ;
5 : BYTE1 DUP 16 MOD 128 + 14337 VSBW ;
6 : BYTE2 16 / 14338 VSBW ;
7 : VOL 2 / 144 + 14339 VSBW ;
8 : DUR SINIT FREQ BYTE1 BYTE2 VOL 20 / 14340 VSBW ;
9 : SIL 3 14341 VSBW 159 14342 VSBW 191 14343 VSBW 223 14344 VSBW
10 0 14345 VSBW ;
11 : PLAY 56 -31796 C! 0 -31795 C! 1 -31794 C! ;
12 : CALLSOUND DUR SIL PLAY ;
13 CR ." ONE VOICE WORDS LOADED & AVAILA8LE"
To emulate CALL SOUND, I have used the information given in TI*MES issue 6, and have placed data into VDP RAM as a sound table, then told the computer to play it.

The CALLSOUND requires three values on the stack, N1 N2 and N3, where N1= duration in milliseconds, N2=volume O-30, N3=frequency in cycles per second.
eg: 600 2 220 CALLSOUND

The operation of the CALLSOUND is the same as a Basic Call Sound using a NEGATIVE duration: a second use will cut short any sound still in progress.

If you wish to use an equivalent to a positive call sound. you need to test VDP Location -31794. This becomes zero when the sound has stopped. C@ is used to place the value in this location onto the stack.

Go to top of page

SINIT tells the computer the sound information is to be stored in VDP RAM. Note the use of C@. We then tell it that we are passing three values.

FREQ took a few seconds to develop, and together with BYTE1 and BYTE2, translates the frequency in cps to the two values the computer wants (see issue 6). We switch the top stack value (frequency) to a floating point number, then input a floating point number. Then we swap these two floating point numbers on the stack, so that the frequency input is again on the top. Then we divide,and change the result to a single precision number.

SIL is placed at the end of the VDP data to switch the sound off after the input duration.


CALL SOUND with ONE or THREE voices: Screens follow...
These screens are a development from the above, and permit you to use either one or three voices. When loaded you may immediately use either one or three:
ONE VOICE: same as CALLSOUND above: N1 N2 N3 CALLSOUND
THREE VOICES: ยท
REQUIRES 7 items on stack, placed in a slightly different order to the standard Call Sound: Time, Volume then Frequency:
T V1 F1 V2 F2 V3 F3 SOUNDX CALLSOUND

Having used three voices, if you then wish to use just one again, you must switch off voices 2 and 3 with V2V3OFF.

To repeat any sound just use PLAY

To alter voice one but leave voices 2 and 3 as they were, just use CALLSOUND

To amend voices 2 and 3 but not one, use SOUNDX on its own: it requires four values on the stack. Then use PLAY to produce the sound.


Here are the screens:
The screen line numbers are omitted from now onwards... but copy to your Forth screen in the same format! Forth screens have lines numbered from 0 to 15, with line 0 usually used for an index comment in brackets!


( CALL SOUND 3 VOICES SJS APRIL 1985. USES VDP 14336 TO 14351 )
( use as Tms V1db F1hz V2db F2hz V3db F3hz SOUNDX CALLSOUND - )
( or Tms V1db F1hz CALLSOUND --- )
: V2V3OFF 161 14340 VSBW 129 14341 VSBW 191 14342 VSBW
193 14343 VSBW 129 14344 VSBW 223 14345 VSBW ; V2V3OFF
: SINIT -31747 C@ 1 OR -31747 C! 9 14336 VSBW ;
: FREQ S->F IF 111860.8 FSWAP F / F->S ;
: B11 DUP 16 MOD 128 + 14337 VSBW 16 / 14338 VSBW ;
: VOL1 2 / 144 + 14339 VSBW ;
: DUR SINIT FREQ B11 VOL1 20 / 14346 VSBW ;
: B13 FREQ DUP 16 MOD 192 + 14343 VSBW 16 / 14344 VSBW ;
: VOL3 2 / 208 + 14345 VSBW : ,
: B12 FREQ DUP 16 MOD 160 + 14340 VSBW 16 / 14341 VSBW ;
: VOL2 2 / 176 + 14342 VSBW ;
: SOUNDX B13 VOL3 B12 VOL2 ;
-->

that final line (-->) is important: it tells Forth to load the next screen as well ..... the next screen MUST follow on, consecutively, from the above screen ......

( SOUND 3 VOICES CONTINUED SCREEN 2 OF 2 SJS APRIL 1985)
: SIL 3 14347 VSBW 159 14348 VSBW 191 14349 VSBW 223 14350 VSBW
O 14351 VSBW ;
: PLAY 56 -31796 C! 0 -31795 C! 1 -31794 C! ;
: CALLSOUND DUR SIL PLAY ;
CR ." 3 VOICE WORDS LOADED & AVAILABLE"
( YOUR CHOICE: ENTER 7 ITEMS ON STACK AND THEN USE: )
( SOUNDX then CALLSOUND or USE THREE ITEMS ON STACK AND )
( CALLSOUND ON ITS OWN. )
( IF YOU WISH VOICE 3 TO BE SILENT ENTER ANY VALID )
( FREQUENCY AND A VOLUME OF 30 )
( USE V2V3OFF TO REVERT TO SINGLE VOICE AFTER USING 3 )
( STEPHEN SHAW )
( NN ALxxxxE ROAD STOCKPORT CHESIRE ENGLAND SKN NAH )

Here are the words we have made available: 
SOUNDX     ( n n n n --- )
CALLSOUND  ( n n n --- )
PLAY       (         --- )
V2V3OFF    (         --- )
This is the most flexible way of handling a CALL SOUND routine I could think of, the only thing lacking being a test of -31794, to enable the sounds to be 'stacked' instead of having just the equivalent of a negative duration CALL SOUND. That little extra I leave to you dear reader!

Note that in Forth. CALLSOUND does NOT have a space in the middle of it!

These Sound screens do require that you have the FLOATING POINT routines loaded as part of your Forth vocabulary.

VSBW is the same as CALL POKEV.
C! = CALL LOAD
C@= CALL PEEK


Go to top of page

TI FORTH SPEECH The following two screens are based upon the theory detailed in TI*MES Issue 6.

The C! is equivalent to CALL LOAD.

Speech synthesiser required.

Not the best laid out screens but space is at a premium in TI*MES!!!
You only need to LOAD the first screen, the --> automatically LOADs the next screen, after a pause.
When LOADing is complete the computer will say READY TO START.
You may then use any of the defined words in these two screens to generate speech.

For instance, if you key in (or use in a definition):
_I AM _A TEXAS_INSTRUMENTS NINETY #9 #4 _A COMPUTER
that is just what the computer will say!

Nothing difficult about these screens. It would be possible to search through the vocabulary for a particular word, and thus open up the full range, but that would inevitably be slower. I leave that program to someone else.!!

Here we are: two screens for speech:
( SPEECH WORDS 9TH APRIL 1985 SJS) CR ." LOADING WORDS .... "
: M -27648 C! ; : SE 64 M 80 M ;
: THAT_IS_INCORRECT 70 M 65 M 72 M 70 M SE ;
: THAT_IS_RIGHT 78 M 79 M 72 M 70 M SE ;
: READY_TO_START 67 M 75 M 70 M 69 M SE ;
: TEXAS_INSTRUMENTS 70 M 73 M 70 M 70 M SE ;
: WHAT_WAS_THAT 73 M 78 M 71 M 71 M SE ;
: NEGATIVE 76 M 77 M 72 M 68 M SE ;
: POINT 76 M 78 M 64 M 69 M SE ; : #1 73 M 64 M 68 M 65 M SE ;
: #3 74 M 73 M 68 M 65 M SE : : #5 65 M 67 M 69 M 65 M SE ;
: #7 72 M 78 M 69 M 65 M SE ; : #9 68 M 70 M 70 M 65 M SE ;
: POSITIVE 67 M 75 M 65 M 69 M SE ; : #0 67 M 76 M 67 M 65 M SE
; : #2 76 M 69 M 68 M 65 M SE ; : #4 71 M 78 M 68 M 65 M SE ;
: #6 72 M 74 M 69 M 65 M SE ; : #8 71 M 67 M 70 M 65 M SE ;
: ANSWER 67 M 65 M 73 M 65 M SE ;
-->

( SPEECH WORDS PART TWO APRIL 85 SJS )
: ABOUT 68 M 65 M 71 M 65 M SE ; : FOURTH 73 M 65 M 77 M 66 M SE
; : AM 64 M 67 M 72 M 65 M SE ; : _A 68 M 78 M 70 M 65 M SE ;
: WORKING 76 M 75 M 75 M 71 M SE ; : PLEASE 67 M 73 M 64 M 69 M
SE ; : PRESS 65 M 67 M 66 M 69 M SE ; : PRINTER 74 M 74 M 66 M
69 M SE ; : NICE_TRY 69 M 74 M 73 M 68 M SE ; : NINETY 78 M 68 M
74 M 68 M SE ; : DISK 77 M 66 M 68 M 66 M SE ; : _ERROR 79 M 78
M 72 M 66 M SE ; : HELLO 74 M 65 M 69 M 67 M SE ; : MEMORY 69 M
64 M 68 M 68 M SE ; : UHOH 68 M 79 M 65 M 71 M SE ; : SORRY 70
M 76 M 65 M 70 M SE ; : TRY_AGAIN 79 M 64 M 64 M 71 M SE ; : LEF
T 72 M 71 M 78 M 67 M SE ; : GOOD 70 M 77 M 64 M 67 M SE ; : SHO
ULD 68 M 66 M 79 M 69 M SE ; : YOU 78 M 75 M 65 M 71 M SE ;
: COMPUTER 68 M 67 M 64 M 66 M SE ; : IS 66 M 67 M 74 M 67 M SE
; : IT 74 M 71 M 74 M 67 M SE ; : PROBLEM 73 M 79 M 66 M 69 M SE
; : SAID 65 M 74 M 74 M 69 M SE ; : _I 67 M 73 M 71 M 67 M SE ;
: HELP 65 M 71 M 69 M 67 M SE ; READY_TO_START

Faster FORTH TRIG... from Sweden...
These two screens give you fast trig for your Forth graphics.

The defined words use ONLY single precision Forth numbers and therefore some adjustment to input and output is required.

In all words, DEGREES are x10, eg to put 90 degrees on the stack, put 900 and if 900 degrees comes off the stack it really means 90 degrees.

RADIANS are times 1000, so 1000= 1 Radian.

This may take a little getting used to, but it makes for greater speed.

You also need to define 2DUP and 2OVER. These can be found on page 1 of Appendix C of your Forth Manual:
: 2DUP OVER OVER ;
: 2OVER SP@ 6 + @ SP@ 6 + @ ;
(The Forth manual only seems to be available in the commercial data DVD The Cyc, available from CaDD Electronics for $25 -plus you need to also buy (or own) PC99 or PC99-Lite. The total cost is WELL worth the investment. The Cyc has everything you could possibly want regarding the TI99/4a)

( Fast trig LES ) BASE->R DECIMAL
: D-R ( deg--rad) 17453 10000 */ ;
: R-D ( rad--deg) 10000 17453 */ ;
: (SIN) ( rad--n) DUP DUP 1000 */ DUP 76
10000 */ 166 - SWAP 1000 */ 1000 + SWAP 1000 */ ;
: SIN ( deg--n) DUP ABS 900 /MOD 3 AND
CASE 0 OF ENDOF
      1 OF 900 SWAP - ENDOF
      2 OF MINUS ENDOF
      3 OF 900 - ENDOF ENDCASE D-R (SIN) SWAP +- ;
: COS ( deg--n) 900 + SIN ;
: (TAN) ( rad--n) DUP DUP 1000 */ DUP 2033 10000 */
318 + SWAP 1000 */ 1000 + SWAP 1000 */ ;
: SQR ( ud--u) 2DUP OR IF -1 0
BEGIN - DUP 1 SRL 2OVER 20VER DROP U/ SWAP DROP
1 SRL - DUP 0 > 0= -->


( Trig cont. )
UNTIL DROP ROT ROT 2DROP ELSE DROP THEN ;
: TAN ( deg--m n) DUP ABS 450 /MOD 3 AND
CASE 0 OF D-R (TAN) 1000 ENDOF
    1 OF MINUS 450 + D-R (TAN) 1000 SWAP ENDOF
    2 OF D-R (TAN) MINUS 1000 SWAP ENDOF
    3 OF MINUS 450 + D-R (TAN) MINUS 1000 ENDOF
ENDCASE ROT +- ;
: (ATAN) ( n--rad) DUP DUP 1000 */ 280 1000 */
1000 + 1000 SWAP *! ;
: ATAN ( n m--rad) 2DUP ABS SWAP ABS >
IF 1000 SWAP */ DUP ABS (ATAN) SWAP +-
ELSE 1000 ROT */ DUP ABS (ATAN) 1571 SWAP - SWAP +-
THEN ;
: ASIN ( m--n) DUP 2DUP 1000 */ DUP 1000 */ 2000 */ + ;
R->BASE ;S


Again you need to have the additional Forth words loaded
(or replace the above usage with the longer form):
2OVER
2DUP
and also
2DROP:
  : 2DROP DROP DROP ;

Very little comment on that one... its for experimentation! Have fun!

Go to top of page

Using TI Forth to format floppy disks:
From an anonymous enquirer who did not send an SAE either...

' I do not have disk manager can I use FORTH to foreat my disks?'

Answer is yes with reservations. TI FORTH on its own can initiallise a single sided single density drive as follows:
Load FORTH and menu choices -COPY and -SYNONYMS.
Place your disk to be formatted in disk drive number one.
Type in: 0 FORMAT-DISK DISK-HEAD
When FORTH has finished, the tracks have been laid down on the disk, and a header has been put on the disk for the Console to use: BUT the disk is full of a file called SCREENS, so, in Basic (or Ex Bas), type in:
DELETE "DSK1.SCREENS" and you end up with a blank initialised disk.


How does it work?
Some words are RESIDENT and thus we cannot see what makes them work... or can we? Using a decompiler I obtained:
: FLUSH LIMIT FIRST - B/BUF 4 + / 1+ 0 DO 32767 BUFFER
DROP LOOP ;

: QUIT 0 BLK ! [ RP! CR QUERY INTERPRET STATE @ 0=
IF ." ok" ENDIF REPEAT ( RP! ) ;

: KEY kEY 127 AND ;
(You will not find kEY in the vocab- using it in
command mode causes a lock out!).

: ABORT SP! DECIMAL 0 ECOUNT ! CR ." TI FORTH" FORTH
DEFINITIONS QUIT ;
and so on .... very few of even the RESIDENT words are
defined in machine code!

Editing Forth screens

Speaking of Forth again .... I have seen in a number of Newsletters the following note: When you have typed EDIT 67 and then want to look at screen 68, just press FCTN 4. You do not need to press FCTN 9 and then type EDIT 68!!!
What I HAVE NOT seen is the converse: with 67 on the screen, you want to go back to 66 .... answer: just press FCTN 6.
This information is on SCREEN #38, where the codes in VED refer to BASIC FCTN key codes. eg Code 2 (FCTN 4) calls +SCR while 0C (=12)(FCTN 6) calls -SCR.



Read about addfreestats visitor tracker, the data your browser reveals and how you may control it.

[ TI Book front page |    TI Resources Page |   TI Articles |   PC99 and MESS Programs ]