Jump down to Rambles by Stephen Shaw || TI Forth for beginners Part 2
Accessing the disk directly at sector level with Minimemory, Editor Assembler or Extended Basic.
About the VDP Registers and using them in Basic.
A small TI Logo procedure
This page contains text scanned from Issue 9 of TI*MES, Summer 1985. The magazine of the UK User Group for the TI99/4A Computer.
Not all text in the issue is readily scannable (and some not easily readable) but text will be added here from time to time, as available.
Our second Users show in Brighton was an enjoyable and successful day. This time we had more opportunities to meet and talk to you and also to show you something of the TI99s capabilities. Two successful introductions at the show were the Doctors clinic and the auction/swap shop. John Rice did a stalwart job of debugging some bugs. as you will see from his article. Lots of people went away clutching bargains from the auction which was a great hit and entertainment thanks to Ivan Nibur.
We have decided to hold another show in the Autumn and the venue is DIGBETH CIVIC HALL. BIRMINGHAM on SATURDAY 26th OCTOBER. Put in in your diary now. Let us have your ideas. Let us have your help. Let us see you there.
It's a small world isn't it. Apart from our contacts with the TI groups in Holland featured in this newsletter. we have recently had contact with TI users from Sweden, Norway. Belgium, USA and Australia. A gentleman from Belgium and Paul Doyle from the Sydney users group visited the Brighton show. It was our great pleasure last month to entertain Albert Lawrence, the librarian of the Newcastle branch of Sydney users group.(Would you believe his brother lives 500 yards away). There is an amazing feeling of camaraderie between TI users which I suspect is lacking with other computer users. If you are feeling lonely and think you are the only TI user in your neck of the woods let us know and we will include your name in the list of area contacts. It could be the beginning of a meaningful relationship.
The computer market remains volatile. Large and apparently successful companies are beginning to crumble. Sinclair is needed a 15m injection of cash. Tiger distribution, one of the larger suppliers has gone into liquidation. The super magazine Personal Computer Weekly has folded. Even the mighty Acorn/BBC has had to be rescued by Olivetti. Is it true that they are replacing the £ sign on the keyboard with a Lira sign, or to be more accurate 20.000 of them. There is a lot of chaff still to blown away (sic) before the market settles down. And we know what its like, we've been there!
We have heard of a new TI CLUB being started in Scotland. They have mailed out to the 3.000 or so ex-members of TIHCUC intending to send out a large glossy magazine but we understand the response has not been good. Not all TI owners are so pathetic are they!
If you wondered what happened to Craig Millars excellent mag. Smart sprite programming let me tell you he has produced three editions which have not been sent to the UK as he was not paid by the UK agent. On top there are to be another 5 issues which can be bought direct at $2.17 each airmail. In case you are wondering when you should renew your subscription please look at your address label. The second number indicates the number of the last issue of the newsletter you receive, IE if you have 9 please renew now.
Happy Computing, Clive
Since expanding the TI 99/4A to a comparatively modest 48K can cost about twice the price of the bare console most TI owners soon develop a keen interest in economical programming. Many users soon learn the usual tricks about keeping variable names short, removing REMs, using OPTION BASE 1 where possible to save array space and so on but for me one of the most interesting techniques is the cramming of as much information as possible into each program line. This can show considerable savings, as each line takes some less-than-obvious memory for things like the line - number itself, length of line, end of line marker and so on. There is often an increase in speed of execution; something not to be sniffed at when working with the TI...
The PRINT statement is about the easiest to start with when considering
memory savings. The print separators - semi colon ( ; ), colon ( : ), comma ( , )
and of course TAB can be
used, with suitable care, to squeeze a lot of information onto one line.
This simple 5 line program shows what I mean.
100 PRINT "FIRST LINE"
110 PRINT "SECOND LINE ";
120 PRINT "FOLLOWING ON"
130 PRINT TAB(17):"TO THE RIGHT"::
140 PRINT "MISS A LINE"
That program can be combined onto one line with hardly any effort, as shown below:-
100 PRINT "FIRST LINE":"SECOND LINE ";"FOLLOWING ON":TAB(17);"TO
THE RIGHT"::"MISS A LINE"
Let's look now at a way of combining several different statements into one
program line. The next program accepts a numerical input and prints the first
and last digits to the screen. I know it's fairly pointless and there may be
mathematical trick to do it but it should illustrate my point.
100 INPUT A
160 PRINT D$
170 GOTO 100
A brief explanation - lines 130 and 140 extract the first and last digits of the string A$ (derived from the input, A), line 150 concatenates B$ and C$ to allow D$ to contain the first and last digits of A$ and line 160 prints D$. All quite neat and straightforward but let's look a little closer. We've used eight lines and six variables to perform a pretty simple string- chopping exercise and a sobering 198 bytes to do it in. We can trim it down to four lines and two variables, using 115 bytes, as shown here.
100 INPUT A
120 PRINT SEG$(A$,1,1)& SEG$
130 GOTO 100
Line 120 is looking a little daunting now but is really only a contraction of lines 120 to 160 of the original listing. Can we squeeze the program a little more and somehow fit line 110 into line 120? Yes, quite easily, and the memory saving is now getting quite impressive.
100 INPUT A
110 PRINT SEG$(STR$(A),1,1)&
120 GOTO 100
This final version of the program uses 74 bytes, saving a whacking 124 bytes over the original, and, if you own Extended BASIC, you could even cram the whole program onto one line and save another 10 bytes.
I find that the best method of compressing lines in this way is to take things a step at a time, first writing the bare routine with one statement per line, just to get the sequence of events clear in my mind. After thorough checking to make sure the routine works as it should, statements can be combined, one or two at a time, until the routine is as compact as possible.
Trying to jump too many steps invariably results in at least one bracket going astray, causing a great deal of brow - furrowing until it can be spotted and corrected. Of course, with practise it becomes possible to thread several of the more usual combinations together without this 'step - at - a - time' technique but I still tend to use the method, particularly on new or unusual routines, the pleasures of debugging having evaporated a long time ago.
In this article I've dealt mainly with string manipulations but the same techniques can be used on many other facets of TI BASIC, notably the extremely useful logical operators, of which more anon.
Who went to THE SHOW? I did, and I thoroughly enjoyed it. Chief memories are of... the salesmanship of Howard Greenberg, who in response to a casual enquiry about disk systems apparently accessed one out of thin air and had me groping for my credit cards. Sorry, Howard. Better luck next time...the impressive display of 3-D tennis and the Mini-Mem drawing routine on the User Group stand...meeting Peter Brooks, who looks remarkably well on one and a half hours sleep a night...the gentleman (I didn't get his name) who is in the process of interfacing his ZX 81 to a TI to use as a programmable command module, if I understood him right...meeting C & A at last, and what nice people they are, and finally the splendid gent from London's East End who programmed his wife's TI and speech synthesiser with all the stock CB phrases and used it to conduct conversations over the air-waves.
I bought a Munchman module at the show and found that it is the first TI module I've owned that has the 'test' facility built in. For those that don't [know] about it, this facility is accessed by holding down SHIFT and pressing 8 3 8 when the title screen appears. By responding to the somewhat cryptic prompts you can enter the game at any level you choose. Even I can get through the first screen with nine munchmen at my disposal. Is there another access code for modules where this system doesn't work, I wonder?
Useless Facts No. 27 - Did you know that the longest English word yet discovered that can be typed on the top row of keys is- TYPEWRITER? There's not many people know that...
After several months use I've decided that the Personal Record Keeping module is one of the more useful items TI has produced, and particularly good value at its present price. After a little practise rudimentary data-bases and spreadsheets are fairly easy to set up and run but oh, the speed! If I thought the display speed was leisurely I just couldn't believe it when it came to sorting. Up to fifteen minutes to sort 60 five-field records strikes me as a little excessive, particularly as I wanted to sort all fields, one after the other. I've heard that the module is programmed, at least partly, in BASIC which would account for it! lethargy; rather a swiz, I thought, but then I wouldn't like the job of writing it in assembly language... (Couldn't it have been compiled? I believe this has been done with other modules.)
I mentioned TRACE a while back and realised I forgot to add a couple of oddities that it throws up. TRACE prints all program lines it encounters onto the screen, right? Not necessarily. Try it with a FOR-NEXT loop for instance and it appears that the program only looks at the FOR... line once, yet it continues to compare the variable with the limit value. So where is it looking? At the stack, I assume. Another statement that TRACE apparently ignores is DATA. A program will contentedly read DATA 'till the cows come home yet TRACE seems to deny it...Hmmm.
One TI module has been getting under my skin for a long time now. What can you do with an Adventure module, except play adventures on it? It contains goodies like a true lower-case character set, underline cursor and, apparently, DISPLAY AT. I've tried, somewhat casually I admit, to get at these facilities via TI BASIC, using the same methods that draw forth Enhanced BASIC from the PRK and Stats modules but with no success. Perhaps some accomplished PEEKer could have a look.
Computer & Video Games magazine added a footnote to a letter they published some time ago, pledging continued support for the TI. They then ran about four issues without mentioning the thing at al1... apparently they promise some TI games reviews in the next issue; I'll believe it when I see it.
Keep an eye open for British Telecom's new office terminal/computer/work- station/anything-else-they-can-think-of, known as TONTO. Does the name stand for anything or was the designer simply a Lone Ranger freak? A brief (very!) inspection showed a most interesting specification at a very reasonable price, but why oh why did they choose Sinclair-type micro-drives instead of a floppy disk system for data and program storage? Happy computing,
Evert and his wife made us most welcome and we spent an enjoyable evening with them. Their national group is run by a committee and produces a newsletter every two months called "TIjdingen", which many of you may recognise as Dutch for TIDINGS. Each issue contains some 40 pages of articles. reviews, programs etc which look extremely interesting and had us rushing for our Dutch-English dictionary. There are some 1400 members of the group scattered throughout the Netherlands and they hold meetings twice a year in Utrect (sic).
Evert explained that there were two TI groups in Holland but only one "official group". The second and original group is run by a businessman, Albert Visser, in Rotterdam. This is known as TIgebruikers and also produces a bi-month1y magazine "TIjdingen". Confused? Well the split from the original group took place due to national restrictions that separate clubs and commercial enterprises. As we were on tour of Holland we called on Albert Visser. It was a pleasant suprise to find that not only does Albert produce a quality magazine for the TI but is also the only main dealer of TI hardware in Holland and Belgium. He had begun to supply goods when they began to get scarce and also to subsidise the cost of producing the magazine. The magazine is similar in style and content to the first Parco magazine and there are 2400 subscribers who also have the benefit of a software library. · .
And why two TIjdingen ? Well Albert originated the name, with a little inspiration from oyer the Channel, and you know what it's like when you have a good idea- everyone wants it. How many other worldwide user groups now have a TI*MES newsletter I wonder?
Clearly the groups compliment each other and both are working towards the common aim of helping and supporting the TI user.- We were left with the impression that Dutch TI users were fortunate in having two quality publications for their computer. Many thanks to both groups for their hospitality. and for donating a number of programs. including the BASICODE translater. to the UK group library.
You may have noticed in Issue 8 that only one LOGO book was reviewed although two were mentioned in the text! Sorry about that, but for the second issue running Clive took the scissors to the second review. Well, I am going to put it at the BEGINNING of this months article ·
LOGO by Anne Sparrowhawk. PAN PCN LANGUAGE LIBRARY.
170 pages. GBP 5,95
A book about LOGO with NO mention of TI????? Hmmm.
Based on LCSI LOGO, most users will be able to transfer the contents to their own Tl LOGO. Lots of procedures. Very interesting procedures too...
PR [WHAT IS YOUR SHAPE CALLED?]
MAKE "TITLE READWORD
MAKE "STRING 
MAKE THING "TITLE :STRING
That is on page 39, and is part of a suite for under 6's. NOT TI Logo admittedly... but can you follow it? with the book you should find conversion easier than with this tiny example.
And how about a 'large character' set! This suite occupies ten pages of the
book... I haven't tried it yet so I don't know if WE have room for it! But it
will illustrate the books depth.
Very good reading and if you have Logo, well worth reading, even if you have not yet USED your logo..it may well inspire you to more worthy things!
Right thats out of the way, some GOSSIP again:
As you may have noticed, TI*MES has become too thin for the volume of material being produced. Clive is doing his best to fit as much as possible into the 64 pages available. To go beyond 64 pages would increase the cost of production quite a bit. If you would prefer to pay more and receive more, let Clive know.
The CMOS chips have some internal diode protection, but this is effective only
when power is flowing: and my mini memory batteries were quite dead. Memo to
all mini mem owners: check the date stamped on your mini mem (the last four
digits of the serial number): first two= week number, last 2 = year I. If your
mini mem is more than two years old, replace the battery NOW.
I must express my thanks to Mr Petry, who replaced my RAM chips and installed NiCad batteries in my mini mem. I need no longer worry about replacement batteries, just ensuring that the NiCads never go flat, by plugging into the console for 14 hours every six months. Mr Petry has advertised in Ti*mes, but I understand no one else has written to him. I strongly urge you to do so!
If you do not use your mini mem for program or data storage, you will not notice the battery becoming flat... so do check the date on the module!
Return to top of page
I have also discovered that my printer (Epson FX8O- update- still working after 28 years!) allows the hash and pound sign to be co resident: I can tell the printer to print a pound sign whenever a CHR$(6) is sent by sending ESC I 1 [ = CHR$(27);"Il"]
To send a CHR$(6) from the TI Writer Editor, you press CTRL & U to obtain the underline cursor, then press SHIFT and F . Press CTRL and U again to return to the normal cursor. Thus I can leave the printer printing hashes (###) which is mighty handy for listings, but print a pound symbol in my letters and so on with no difficulty at all.
Memo to lan Swales: in the UK the VDP interupts are every 50th of a second, not every 60th of a second as in the NTSC model.
Congratulations Graham Baldwin on ROLLERBALL published recently. Hope too many TI owners were not put off by the SPECTRUM banner which headed the program (these magazines!).
The video output socket shown on page 26 of issue 8 is great for our US friends, but PAL models use a SIX pin DIN plug, not the NTSC five pin DIN plug!! A previous issue of TI*MES has given details of connecting a metal boxed TI modulator to the COMPOSITE VIDEO input of a video recorder or monitor - for full colour too.
MPE in Southampton do a lot of FORTH advertising so I sent for a catalogue.
After several months one arrived: 16 pages of A4, and I could not follow a word of it. If you would like to buy floating point routines for the Z80 for slightly under one hundred pounds, fine. TI have provided them to us as standard! Waste of a postage stamp as far as I was concerned.
Amendment to TI Forth initial release:
In TI Forth some SPRITE definitions were revised in 1983.
Use your main system disk to look at TI Forth system screens 58 and 59: use 58 LIST then 59 LIST.
Look at the dates at the top of the page. what year? lf 1982, you need to make the following amendments:
Type 58 EDIT.
Change line 10 (part of SSDT definition):
formerly: ... 80 0 VFILL ENDIF
to become:... 80 0 VFILL 300 ! SATR ! ENDIF
Use FCTN 9 [back] and when back at the bottom of the screen (having removed the disk write protect tab!) type FLUSH.
Type 59 EDIT, and make amendments as follows:
Line 7 (part of SPRITE definition)
formerly .... I 2 VMBW ENDIF ....
to become: .. I 2 VMBW DROP ENDIF ....
Line 9 (part of MOTION definition:)
Formerly: ... + >R 100 U* DROP + SP@ ...
to become: .. + >R 8 SLA SWAP 00FF AND OR SP@ ...
Use BACK and FLUSH to disk.
To be really efficient, you may wish to change the dates on the screen from 1982 to 2OOCT83!!!
ORIGINAL SOURCE:Notice: Labels exist only for your original source code. They do not exist in the object code and so cannot be recovered. Whatever the address of the label is, that address will be used in the disassembled listing.
TISUB EQU >2D14
GETTIM EQU >282C
NS EQU >3ADC DISASSEMBLED OBJECT CODE
KEY EQU >253D using Navarone Super Bug
STRREF EOU >2014
STRAS EQU >2110
DONE EQU >2C08
BLWP @TISUB A000 BLWP @>2D14
BLWP @GETTIM A004 BLWP @>282C
DATA 2,NS A00B DATA >0002
A00A MPY *R12,8
INC R0 A00C INC R00
LI R1,1 A00E LI R01,>0001
MOV R8,R2 A012 MOV RO8,R02
and so on.
DATA (NS) has been 'translated' into an inapplicable operand. You need to look at an ASCII dump and to have some slight idea of what is going on! TEXT is also mistranslated into strange commands.
A dissasembler CAN be useful, but it does not give you the source code as originally keyed in! If you have been thinking of obtaining a dissassenbler, maybe this note has helped you see what one can do!
SXB UPDATE: Further to my review in issue 8, I now have the first 17 issues of SXBrief, and the disk of code relating to the first 15 issues, which also includes two screen dump programs and a disk cataloguer. As I said last time, an expensive package on its own, but the extras are very reasonably priced and together they provide excellent value.
An example of my use of SXB, to sort names alphabetically:
100 CALL CLEAR
110 DIM A$(60)
120 FOR T=1 TO 60
130 INPUT:"INITIALS etc":B$
135 IF B$="END" THEN 200
140 INPUT "SORTING NAME":C$
150 CALL LINK("SMFIX",B$,10)
170 NEXT T
210 CALL LINK("DBKEYS",DES$,V)
215 CALL LINK("DBSORT",A$(),VEC)
220 OPEN #1:"PIO"
230 FOR T=1 TO 60
260 CALL LINK("SMTRIM”,B$," ")
265 IF B$="" THEN D$=C$ :: GOTO 280
270 O$=B$&" "&C$
280 PRINT #1:O$
290 NEXT T
CALL INIT :: CALL PEEK(-3186and of course PRINT A;B;C;D;E;F;G;H - write these value down
8,A,B,C,D) :: CALL PEEK(-319
Key in (using those written down values!!!):
CALL LOAD(-31868,A,B,C,D) :: CALL LOAD(-31952,E,F,G,H)
NB: One line of the program will be corrupted... the 'oldest' line to be entered.
Computer Art and Animation A Users Guide to Tl99/4A COLOR LOGO by D D Thornburg. Addison-Hesley. ISBN 0-201-07958·5 pb 214pp
Around twelve pounds.
With LOGO receiving such little attention a book is very nice... especially when it is for the TI! This book sets out to deal with only a particular aspect of LOGO: Art! It concentrates heavily on the Turtle, with a mere 18 pages on the use of sprites. It is an easy read, with lots of mainly blank pages! Not in the least intimidating, and a fresh outlook is always welcome.
BASIC REFERENCE MANUAL, SAMS from Clive when available...
Available to download online from TI99/4a books.
Super little book, why didn't I have it in 1981 ('cos it was written in 1984!). Deals mainly with TI Basic and goes into some detail on each command with lots of examples. I did miss a good example of the POWER of the POS function (I suspect only Pete Brooks knows about it!) but logical operators are well covered. Excellent detail, good appendices. Recommend.
Does NOT cover more complex issues such as sprites or sound: but after reading this book, you will be ready for the slightly more meaty books which are available. An excellent book. Vote of thanks to Ray Kazmer who kindly sent me a copy. You will be able to obtain it from any good bookshop, to order.
BOOK REVIEW: FORTH TECHNIQUES. by R Olney & H Benson. PAN BOOKS. paperback.
253 pages, around seven pounds. ISBN 0 330 28961 6
This is the second PAN book on Forth. The first 'primer' is FUNDAMENTAL FORTH by the same authors. This book goes a bit beyond primers... and looks at ways of "extending your system". General Forth programming techniques are explored through useful example routines. Quite a few of the extensions are 'standard' in TI Forth, and the chapter on controlling hardware is not exactly relevant, but this book does give you a very good deep look into the possibilities of Forth, and the examples of Forth programming, even if not directly relevant, are still educational. A good third book to buy, after Brodie and Scanlon.
This program requires the mini memory and a BLANK initialised disk. It will use disk sectors 21 to 24. It DOES NOT use file names and the disk manager will not show the files as used.
Later a more general program will be given together with amendments for Editor/Assembler and Extended Basic.
50 REM DISK SECTOR ACCESS
60 REM FOR MINI MEMORY
70 REM DUMP SCREEN CONTENTS
CHARS AND COLOUR ONLY
80 REM NOT CHAR DEFS!
TO DISK THEN READ THEM
100 CALL CLEAR
110 CALL INIT
120 PRINT "STARTING ...... ”
129 REM D=DISK DRIVE NUMBER
139 REM S=BASE SECTOR
149 REM B=BASE NUMBER FOR
158 REM C=0 MEANS WRITE
159 REM C=255 MEANS READ
169 REM LETS DUMP FIRST K
OF VDP, EG SCREEN PLUS
170 FOR T=0 TO 3
171 CALL HCHAR(1+T*6,1,42+T*
172 CALL VCHAR(1,1+T*6,65+T*
180 NEXT T
190 FOR T=O TO 3
200 GOSUB 240
210 NEXT T
220 PRINT "NOW CHANGE LINE
160 TO C=255 AND RUN PRO
GRAM AGAIN":"":"USE CLEAR (B
221 PRINT "ALSO BYPASS 171 B
Y INSERTINGLINE 171: GOTO 20
0":"AND ADD LINE 219: GOTO 2
230 GOTO 230
240 IF S>20 THEN 260
248 REM 14700 IN DISK AREA
HENCE SAFE. POINTED TO
BY LAST TWO BYTES IN
249 REM LINE 330. COULD BE
ANY VDP ADDRESS.
250 CALL POKEV(14700,1,16)
259 REM INCREMENT SECTOR
AND CONVERT TO TWO BYTE
289 REM INCREMENT BUFFER
ADDRESS AND CONVERT TO TWO
BYTE FORMAT (A DIFFERENT
319 REM NO NEED TO RELOAD
WHOLE ROUTINE ON SECOND
AND SUBSEOUENT PASSES.
320 IF S>21 THEN 360
328 REM D=DISK C=READ/WRITE
329 REM LAST TWO BYTES POI
NT TO ADDRESS IN LINE 250
330 CALL LOAD(32000,131,76,0
339 REM THE ACTUAL M/C
340 CALL LOAD(32016,2,0,125,
348 REM LETS GIVE THE
ROUTINE A NAME... 32760 I
S REF/DEF FOR MINI MEM.
349 REM FIRST 6 BYTES= NAME
, LAST TWO= ENTRY POINT
(125*256 +16 =32016)
350 CALL LOAD(32760,84,73,42
360 IF S=21 THEN 390
369 REM CHANGE BUFFER AND
SECTOR INFO ONLY:
370 CALL LOAD(32006,B2,B1,S2
380 GOTO 400
389 REM POINTER TO 32760:
390 CALL LOAD(28702,127,248)
400 CALL LINK("TI*MES")
The preceding program dumps the screen display to disk. A few minor changes, as shown in the program, and the program will read that data back in, fairly quickly. I have here saved the first 1k of VDP (4 sectors) which includes the screen and colour info but not character definitions: you need to save at least another two sectors to store the characters as well.
100 CALL CLEAR
110 CALL INIT
120 PRINT "DISK UTILITY"
130 CALL POKEV(l4700,1,16)
140 INPUT "DISK NO:":D
150 INPUT "SECTOR NO:”:S
180 PRINT "ENTER":"1.TO READ
190 INPUT C
210 PRINT "RECOMMENDED BUFFE
R AREA":"14800 and OVER"
220 INPUT "BUFFER ADDRESS:":
250 CALL LOAD(32000,131,76,0
260 CALL LOAD(32016,2,0,125,
270 CALL LOAD(32760,84,73,42
280 CALL LOAD(28702,127,248)
290 CALL LINK("TI*MES")
line 250: for ED/AS: Use 12288 instead of 32000:
250 CALL LOAD(12288,131,76,0
LINE 260: Ed/As:
260 CALL LOAD(12304,2,0,48,
,91) line 280 .see below
Line 270: Ed/As:
270 CALL LOAD(16168,84,73,4
Line 280: Ed/As:
280 CALL LOAD(8234,63,40)
Return to top of page
General Purpose Disk Utility for Extended Basic with 32k ram:
Using Editor Assember or Mini Memory modules, the user has access to Device
Service Routines - eg the subroutines in the peripheral roms - via DSRLNKs.
Unfortunately, Extended Basic provides no such luxury.
We CAN write a DSRLNK for Extended Basic, but that would involve a bit more code than our simple little program here needs.
Therefore below you will find an adjusted listing, for ExBas, together with the equivalent source code for lines 255 and 260. You don't need this but it shows you what we are doing.
This routine directly accesses the disk controller card, and therefore the routine will work ONLY with the TI Disk Controller Peripheral Card.
GENERAL PURPOSE DISK UTILITY
FOR EXTENDED BASIC.
100 CALL CLEAR
110 CALL INIT
120 PRINT "DISK UTILITY"
140 INPUT "DISK NO:":D
150 INPUT "SECTOR NO:":S
18O PRINT "ENTER":"1.TO READ
190 INPUT C
210 PRINT "RECOMMENDED BUFFE
R AREA":"14800 and OVER"
220 INPUT "BUFFER ADDRESS:":
250 CALL LOAD(15360,131,76,0
255 CALL LOAD(15410,200,11,6
260 CALL LOAD(15436,2,12,17,
270 CALL LOAD(16376,84,73,42,
280 CALL LOAD(8196,63,248)
290 CALL LINK("TI*MES")
I am indebted for this information (especially for the m/c routines) to Richard Blanden.
Source code equivalent to lines 255 and 260 in the Extended Basic listing above:
LABEL MOV *R0+.*R1+
LWPI @>83E0 *END LINE 255 here
LI R12,>1100 *CRU address of disk
BL @>5B38 *Address in card
B *R11 *RETURN
Our fairly full Forth BSAVE took up from screen 51 to screen 61.
The following screens cannot then be used for our programs:
0/5 : Used by the system
44 : TRACE ( not Bsaved. You may want to load it later)
51/61 : Our Bsaved area!
68/71 : FILE ( not Bsaved. May wish to use it later)
74/75 : Code and Assembler. as file above.
BB : CRU (as above)
The Forth loading program which contains the "kernel" of Forth is held on Screens 5 to 21.
If you have prepared your Forth copy disk per the last issue of TIMES, if you copy two parts of the disk onto all your blank disks, they will have almost all of TI Forth on them to draw on. Then the other screens are available for you to use. Add any of the above screens as you need them.
Copy with SCOPY or SMOVE screens 0 to 21 (Kernel) and 51 to 61 (BSaved).
If you have loaded EDITOR into the Bsaved portion, you may wish to retain the
64Support on your disk: it is on screens 22 to 29
If you have used 64Support in your Bsaved version, then you may wish to retain the 40 column EDITOR which is on screens 34 to 38.
ALL other screens are in the Bsaved portion! You may therefore use them to save your programs to. You may also wish to set up a disk especially for your programs, with nothing of the Forth language on it. This is ideal for two disk drive owners who can keep the System disk in Drive 1 and the program disk in drive 2.
If you wish to set up a blank disk with empty FORTH screens, to hold your programs, place it in drive 1 and enter: 0 FORMAT-DISK
Also, copy the error messages, screens 4 and 5.
If you have two drives you could use SCOPY or SMOVE. If you only have one drive, the simplest way to copy them is to load eg screen 4: 4 EDIT then add your initials to line 14 and FLUSH to the new disk. Repeat for screen 5. .
To enter a program onto a Forth screen, if you wish to use say Screen 15, type: 15 CLEAR 15 EDIT
If the disk is in drive two, the position of screen 15 is now called Screen 105!!! (eg add 90). FORTH only uses the disk number for the FORMAT command.
When accessing screens you do so only by screen number. Disk one is 0-89, Disk two contains 90-. .
Now, lets try to key in a simple screen to demonstrate writing, saving, loading and running a FORTH program.
I have selected the MULTICOLOUR mode to demonstrate: my TI Forth manual gives an incorrect definition of one of the words used!
Decide which screen you wish to save the program to, then key in:
N CLEAR N EDIT where N is your selected screen number!
Enter the screen shown below, exactly as shown. When you have finished, press FCTN and 9 [BACK] and then enter FLUSH to write the screen to your disk.
The screen has been written to auto run, by using a defined word on the screen. To load the screen, key in N LOAD where N is the number of the screen.
The word we had difficulty with is MCHAR. According to my TI Forth manual, this word uses a 24 x 32 screen, sets four blocks of colour, and takes six values from the stack. It doesn't, not on my Forth!
It takes three values from the stack, N1 N2 N3, where N1 is the colour (0 to 15), N2 is the column (0 to 63), N3 is the row (0 to 48). If anyone has a TI Forth Manual which describes MCHAR in this manner, or has a copy of TI Forth which needs six values to run, please let me know!!!!
SCR #18 (that means this is screen 18 on my disk)
0 ( NEIL LAWSON MULTICOLOUR DEMO)
1 : STT MULTI MINIT RANDOMIZE DECIMAL ;
3 : PRT 16 RND 64 RND 48 RND MCHAR ;
4 : PTN 3000 0 DO PRT LOOP ;
7 : S 64 0 DO
8 48 0 DO 16 RND J I MCHAR LOOP
9 LOOP ;
10 : MCP STT S PTN TEXT ;
11 MCP TEXT CLS
12 ." ENTER 'MCP' TO DO AGAIN"
LINE 0: DESCRIPTION. Words in brackets are REMS. Leave a space after open bracket. Line 0 of each screen can be inspected using the INDEX command, useful for finding screens! (eg 1 89 INDEX)
Line 1: Sets up multicolour mode, places random seed and tells computer any numbers it may meet are in decimal base.
Line 3: PRT switches on a random block in a random colour.
16 RND gives a random colour fron 0 to 15 and so on.
Line 4: Simple loop to switch on 3000 blocks at random.
DO...LOOP is equivalent to FOR...NEXT.
In this case: FOR I=0 TO 3000
switch block on
Return to top of page
Line 7: Leaving the computer to switch on random blocks left big chunks of
black for rather a long time, so I decided to switch every block on first, then
vary the colours randomly. S is a Nested Loop! and is equivalent to:
FOR COLUMN = 0 TO 63
FOR ROW = 0 TO 47
COLOUR = INT(RND*16)
set block: colour, column, row
To use the value of the loop counter, we use I and J.
I is used for the innermost loop, and J for the second innermost loop.
Using I and J places the relevant value on the stack where we can use it.
The count starts with the value on the top of the stack when DO is reached (zero in these cases). When LOOP is reached, the counter is increased by one. If it then equals or exceeds the next value on the stack (64, 48), that is the end of the command. This differs from Basic, which increments the counter, goes through the loop and THEN tests for the maximum value. In FORTH the maximum value is not used in the loop.
Line 10 defines the word which makes it all happen ... notice we switch back to TEXT mode afterwards!
Line 11 is an auto start : the computer will perform MCP as soon as you LOAD the screen. After the first run, it switches back to TEXT mode, clears the screen, and reminds you of the command word.
. [stop] means PRINT (to screen here) and . " text" is PRINT "text"
Note the space after the opening quotation mark!
Even if you lack any of these extras, the article may be of interest in
revealing a little of the consoles internal working.
VDP is a TI first: a separate computer chip which does all the display work. On the 99/4A the chip is also made to pass Basic program data to the main processor. Widely used (for instance in the MSX machines) the VDP Processor is the most costly integrated circuit in your console, currently costing some GBP 15.00.
The VDP Registers hold information which controls the essential workings of the VDP... and I shall start with a look at the first register! Not all the registers will be dealt with in such detail, but there is a summary at the end.
VDP REGISTER ONE is a multipurpose register, controlling several different aspects of console operation. By changing the value in this register we can adjust:
4/16k selection ; Screen blank; VDP Interrupt switch; graphics modes; sprite sizes.
The basic address of vdp register one is -32512
To this is added the value of each of 8 control bits.
The nomsal value is 224:
Bit 0, value 128 = 16k selected
Bit 1, value 64 = screen enabled
Bit 2, value 32 = interrupts enabled
Bit 3, value 0 = NOT 40 column text node
Bit 4, value 0 = NOT multicolour mode
Bit 5, value 0 = Has to be a zero here
Bit 6, value 0 = standard sized sprites
Bit 7, value 0 = unmagnified sprites
(Bit 7 is 0 or 1 having a digital value of 0 or 1,
Bit 6 is 0 or 1 having a digital value of 0 or 2,
Bit 5 has a value of 0 or 4,
Bit 4 has a value of 0 or 8 and so on...)
REFERENCE: Editor Assembler Manual Pages 326/327
Adding the digital value of each bit (128 + 64 + 32) we get 224.
To set the register we use CALL PEEKV with mini memory.
EXAMPLE: If we wish to set just bits 0 and 2, 128 + 32 = 160 and 160 - 32512 is -32352.
With this value, bit 1 is zero, or screen not enabled.
In your program insert: CALL PEEKV(-32352,A)
Note that A is a dummy variable which is required, but it is only the memory address in the peekv that actually does the work.
Now, the screen can be set up with any text or graphics and while we are setting it up, the viewer will see only a blank screen ( unless he presses a key!).
You can instantly switch the screen back on with: CALL PEEKV(-32288, A) where -32288 is made up from 224-32512.
Look at the normal bit settings above: to turn the screen off, we need to turn the value of bit 1 to 0, that is subtract 64 from the normal register value (224-64= 160= address 160-32512) .
Now experiment with other settings of register 1.
NB: If you disable the interrupts, you switch off the key scans etc & end up with a 'hung-up' console
Try to use different sized TI BASIC sprites!
VDP Register Two
REGISTER TWO defines the base address of the Screen Image Table.
If you reserve a chunk of VDP memory (either using CALL FILES if you have a disk drive, or CALL LOAD(-318B8,A1,A2)if you don't) then you can set up a screen display (or displays) and just by one CALL PEEKV, instantly change the entire screen display.
This register is switched in chunks of a full one k, 1024 bytes.
BASIC ADDRESS: -32256
NORMAL START ADDRESS: 0
Reset to normal: -32256 +1024*0 = CALL PEEKV(-32256,A)
This little program is pretty impressive and uses VDP register 2 to build up an
alternative display which can be instantly recalled.
It is necessary to reserve an area of memory for the second display: see the initial rem statements.
When RUN, an initial design of horizontal bars will appear, and will shortly be followed by a blank screen. when the second design appears, press SPACE for a quick demonstration!
1 REM USING VDP REGISTER
2 REM TO INSTANTLY CHANGE
3 REM SCREEN DISPLAY
5 REM BEFORE KEYING IN OR
6 REM LOADING THIS PROGRAM
7 REM RESERVE MEMORY:
8 REM IF YOU HAVE A DISK
9 REM SYSTEM, USE
10 REM CALL FILES(8), THEN
ll REM NEW
12 REM ELSE KEY IN
13 REM CALL LOAD(-31888,56,
0) THEN KEY IN NEW THEN LOAD
100 CALL CLEAR
110 PRINT "WAIT A FEW MINUTE
S WHILE THETWO SCREENS ARE S
120 FOR T=0 TO 5
130 CALL COLOR(T+9,T+2,T+2)
140 CALL HCHAR(1+T*4,1,96+T*
150 NEXT T
151 REM NOW TRANSFER TO
2ND SCREEN AREA:
160 FOR Z=1 TO 768 STEP 24
170 CALL PEEKV(Z,A,B,C,D,E,F
180 CALL POKEV(Z+14336,A,B,C
190 NEXT Z
191 REM BLANK SCREEN BEFORE
200 CALL PEEKV(-32352,A)
210 PRINT "PRESS SPACE FOR N
211 REM AND TRANSFER TEXT T
O BOTTOM OF 2ND SCREEN
220 FOR @=705 TO 768 STEP 32
221 REM NOTE USE OF @ AS A
230 CALL PEEKV(@,A,B,C,D,E,F
240 CALL POKEV(@+14336,A,B,C
250 NEXT @
260 CALL CLEAR
261 REM CLEAR SCREEN AND
SWITCH DISPLAY BACK 0N...
270 CALL PEEKV( -32288,A)
280 PRINT "SECOND SCREEN BEI
290 FOR T=0 TO 5
300 CALL VCHAR(1,1+T*5,96+T*
310 NEXT T
320 PRINT "PRESS SPACE FOR N
330 CALL KEY(3,A,B)
340 IF A<>32 THEN 330
341 REM A SIMPLE PEEKV WILL
CHANGE TO SCREEN TWO:
350 CALL PEEKV( -32242,A)
360 CALL KEY(3,A,B)
370 IF A<>32 THEN 360
380 CALL PEEKV( -32256,A)
390 GOTO 330
if you glance at your Mini Memory Manual, you will see on page 75, that TI claim the 'standard' Sprite Attribute List is using VDP memory locations 768 to 895. There is therefore enough room for 32 sprites... or is there?
In fact, TI have shown an incorrect start address for the pattern colour table, as the colours for the cursor and the edge of the screen are held in location 895. In order to use 32 sprites without spoiling the screen colour, we need to move the sprite attribute list (SAL for short).
This we are permitted to do. Page 327 of the Editor Assembler Manual refers.
Return to top of page
The address at which the Sprite Attribute List (henceforth: SAL> can be found
is stored in VDP REGISTER 5.
The value of this register (which can only be written to, not read) can be amended in a TI BASIC program, using Mini Memory, by using CALL PEEKV.
That was not a misprint: we use PEEKV to WRITE to the register as follows: Each of the VDP registers has a basic memory value allocated to it. The value of the registers is changed by peek'ing a memory address which is offset from this basic value.
The basic address for VDP register 5 is -31488.
The normal SAL starts at address 768, which is 6 x 128.
Thus we can vary the SAL in units of 128: each offset=128.
To have 32 sprites on screen, we need 32x4=128 bytes of memory which will not be corrupted by the TI BASIC program. An apparently safe area can be found around VDP address 1536-> which is usually used to store the definitions of characters 97 onwards.
To move the SAL to start at 1536, we divide 1536 by 128: 1536/128 = 12.
we then add this offset to the basic address for register five:
-31488 + 12 = -31476
As you can see from the listing, to move the SAL we merely use:
CALL PEEKV(-31476,A) [The variable A is a dummy but necessary]
NB: There is no need to reserve memory for this program. (MINI MEMORY REOUIRED).
100 REM MOVE SPRITE TABLE
110 CALL PEEKV(-31476,A)
130 CALL CLEAR
140 PRINT "HOW MANY SPRITES DOES A":"TI99/4A HAVE?"
150 FOR RT=1 TO 120
160 FOR SP=0 TO 31
170 CALL POKEV(1536+SP*4,RT+
180 NEXT SP
190 NEXT RT
200 GOTO 150
220 REM TO RESTORE SYSTEM
230 REM KEY IN:
240 REM CALL PEEKV(-31482,A)
This short program will produce 32 sprites, slowly moving down the screen.
we have seen how mini memory can be used to change two of the VDP registers to produce a usable effect.
All of the registers can be changed in the same way, and details can be found in the editor/assembler manual, pages 326/327.
REGISTER ZERO is a multi purpose register, only one bit of which has any relevance to the TI99/4A. This is used to select bit map mode. It does not seem to be of use from TI Basic.
REGISTER ONE is dealt with above.
REGISTER TWO defines the base address of the Screen Image Table.
See above for an example.
REGISTER THREE is the base address of the colour table. You can instantly change the colours of every colour set by switching the base address of the color table. As above, you need to reserve memory, and place your alternative table into the reserved memory area, then switch into it, and out of it.
Basic Address: -32000
Normal Start Address: varies:-
TI BASIC: 768, EX BAS: 2048, Machine code,Ed/As:896
Reset to TI Basic Normal: -32000 + ( 13 * 64) = CALL PEEKV(-31232,A)
(Multiplier is 64. The first address is the values for the colour of colour set number one.)
REGISTER FOUR: base address of the pattern descriptor table. In TI Basic, the register has a value of 0 and therefore points to the same area of memory as the screen: BUT: the screen occupies only 0 to 768. The pattern descriptor table is in chunks of 2k, and thus with a base of zero, the top is at 2048. In TI Basic, you will find the character patterns described from locations 1008 to 2040.
Thus, although the two tables occupy the same area of memory, they do not conflict. However, this does explain why you cannot define characters with ASCII values under 30 or over 143. There is not enough unused table.
This also explains why, when using Sprites with TI Basic and Mini Memory, you do not use the actual ASCII value, but a larger number, to point to the correct pattern description in the table: normally the console will calculate the offset for you, but using CALL POKEV in this way, we need to add the offset on for it.
Basic address: -31744 Multiplier:2048
eg -31744 +1 = CALL PEEK(-31743,A) will locate table at 2048.
(NB: It will point to 2048 as start of table: it is up to you to actually place meaningful values in there
REGISTER FIVE: base address of sprite attribute list. Dealt with above.
Basic address: -31488 Multiplier: 128
NOTE: We are not given the opportunity to relocate the SPRITE VELOCITY TABLE.
The Sprite Velocity Table expects to find the Sprite Attribute List at 768, and automatic motion of sprites is not possible unless the SAL is found in this ‘normal' position.
REGISTER SIX: base address of the SPRITE DESCRIPTOR TABLE.
In Extended Basic (& TI Basic with Mini Mem) the Sprite Descriptor Table uses
the SAME memory area as character descriptions. This enables us to give the
ASCII value of a charactor to indicate what we want our sprite to look like.
However, when using machine code, this table can be relocated which enables us to use 32 sprites which do not look like any of the definable characters.
The BASIC ADDRESS is -31232 Multiplier: 2048
REGISTER SEVEN: a dual purpose register.
Bits 0 to 3 carry the colour code of the foreground colour when using the 40 column text mode, while bits 4 to 7 carry the colour code for the SCREEN.Of little value from Basic.
Basic address is -30976
The default value of the register is >F5 (245) when using the Editor Assembler, but with TI BASIC or Extended Basic, the register has a normal value of >07 (Decimal 7, Binary 000001111. This value of 7 equates to a COLOR CODE of 8, Cyan.
The editor assembler manual incorrectly gives a Basic default value of >17
[ TI Book front page | TI Resources Page | TI Articles | PC99 Programs ]