Programming Tips for Timex Sinclair Computers

Authors

Publication

Pub Details

Date

Pages

BASIC Terms

Some tricks I have picked up over the years are ways to save memory on your TS Computer. This are great to know tricks when dealing with low memory systems like TS 1000, TS 1500 and ZX 81 computers. It is also helpful on the TS 2068 when the out of memory error appears.

The most common way is to set up a variables that you can run then delete. Some programmers use roman numerals and assigned numeric values to them. i.e. LET X=10, LET XX=20, LET XXX=30, LET C=100, LET CC=200, LET CCC=300, LET K=1000, LET KK=2000, and so on. After the program is finished and tested and all the variables work, delete the lines that set up the LET Statements. You must use GOTO to restart the program so the variables are still in memory even though they don’t appear in the program anymore. You cannot use any RUN or CLEAR commands as they will delete the variables from memory. With this procedure you can use any variable name you wish, so use something you can remember easily. Some suggestions are MENU for the main menu LP for the printer routine, SORT for a sort routine. These variables labels would contain the start line number for that routine. In the below routine X is established as a value of 10. TEST is printed at Column 10, row 10 until the X key is pressed.

10 LET X=10
20 PRINT AT X,X; "TEST"
30 IF INKEY$="X" THEN STOP
40 GOTO X

Another way to save memory is using the VAL function. VAL returns the numeric value of a string. The idea is to store values in strings instead of numeric variables. The numeric variable uses more memory than the string. The number 10 line in the following routine uses 17 bytes of memory. The same thing is done by line 20 which uses 14 Bytes. Numbers use about 7 bytes per number.

10 LET C=100
20 LET C=VAL "100"

For 4 digits or larger numbers in multiples of 100 you can use another way to store numbers. VAL “6e3” is the same as 6000 or 6 followed by 3 zeros. The “e” within the string tells the computer 3 is the number of zeros following the 6.

Some numbers can be shown by a fixed formula. The functions NOT PI=0, SGN PI=1, INT PI=3 are three of the most common I use. Here are some ways to use this method. The lines in column A do the same thing as Column B, but A uses less memory. On the TS1000, TS 1500 and ZX 81 models use PI symbol below the M key.

Column AColumn B
10 FOR N= SGN PI TO INT PI10 FOR N=1 TO 3
20 PRINT AT NOT PI, SGN PI;20 PRINT AT 0,1;
30 LET A=INT EXP PI30 LET A=23
40 POKE VAL "3e4",NOT PI40 POKE 30000,0

On the TS2068 and Spectrum you can use the 23 and 24 line within your program by using a Print #1; command. As in the case of the INPUT command there is no prompt so the program continues unless there is a PAUSE command as shown below.

100 PRINT #1; "This is what would be printed." : PAUSE NOT PI

When a key is pressed the pause is released and the program continues.

If you would like to input only capital or only lower case letters on the TS2068 or Spectrum this can be done by poking the flag that controls the upper and lower case cursor.

100 POKE 23658,8 (Capital letters only)
101 POKE 23658,0 (Lower case letters only)

You can also adjust things like the Scroll, Speed of key return, and Keyboard Click by poking the variables below.

SCROLLINGPOKE 23692,#(#=any number from 1 to 255)
KEYBOARD CLICKPOKE 23609,#(#=any number from 1 to 255)
KEY RETURNPOKE 23561,#(#=any number from 1 to 35)
KEY RETURNPOKE 23562,#(#=Any number from 1 to 5)

Key return can be used to speed up the control for games or touch typist, but beware!!

I get questions about program conversion from ZX 81, TS 1000, 1500 which we call group 1 to group 2 which are T-2068, TS 2068, Spectrum and Spectrum+ and vice versa.

There are several commands added to the Spectrum, plus four more commands on the TS 2068 that cannot be found on the group 1 models. With the exception of the list in table 1 most of the other commands in BASIC are the same on both the Timex and Sinclair models.

Group 1 models has two commands which are not found on group 2 computers, These are SCROLL and UNPLOT. They should cause you few problems when converting from group 1 to group 2 models (See table 1). On the other hand there are quite a number of commands found on group 2 that are not found on group 1 (See table 3). The commands in table 3 which have * beside them can be duplicated on group 1 models as shown below in table 2.

The command PLOT appears on all the models in group 1 and 2 but is used differently in each group. PEEK and POKE are also on both groups but the addresses of these must be changed to work with whatever model you are using. A command like POKE USR “a” on group 2 models indicating User Defined Graphics has no equivalent at all on group 1 models, so you will have to omit this and use a standard character instead.

The functions CODE and CHR$ also are in both groups, but the character set are different so you use the Character values for that group (see table 5). The left number in the CODE # column is the code equivalent of the group 1 model.

PRINT USR X or RANDOMIZE USR X functions are used the same, but the address may be different depending on the amount of memory available. The start of BASIC is changed when add interfaces to the system like with the ZX Interface 1 and Rotronics Wafadrive in group 2 models.

Table 1 — Group 1 to Group 2 conversions

Group 1Group 2
SCROLLRAND USR 3582

A variable may be used to select this option. e.g. LET T=USR 3582

Group 1Group 2
PLOT X,YPRINT AT 21-Y/2,X/2;

Print the appropriate quarter square graphic character.

Group 1Group 2
UNPLOT X,YPRINT AT 21-Y/2,X/2;

Print a space, or the appropriate quarter graphic square character.

Table 2 — Group 2 to Group 1 conversions

Group 2Group 1
BIN
eg: LET Y=BIN 10010101
LET Y=(Decimal number)

BIN, used with UDG, allows the representation of a number in binary. For group 1 change the BIN to a decimal number equivalent.

Group 2Group 1
READ/DATA
eg: READ x,y
    DATA 50,60
LET X=50
LET Y=60

READ and DATA are used to store data in the program. Use LET instead with Group 1 models or enter the data in an Array.

Group 2Group 1
DEF FN and FN
eg: DEF FN a(x)=SQR x
    LET t=FN a(i)
LET X$="SQR X"
LET X=1
LET T= VAL X$

The defined function can appear in a string. Use the Keyword for built-in functions (SQR). The equivalent of FN may need 2 lines.

Group 2Group 1
PLOTNo Equivalent
eg:SCREEN$
  LET a$=SCREEN$ (x,y)
LET A=PEEK(PEEK 16396+256*PEEK 16397 + 1 + Y + 33 * X)

Used in interactive games to detect characters in the display file (use with 16K only).

Table 3 — Group 2 commands not found on Group 1 models

Commands & functions on all Group 2 models
ATTRBEEP
*BINBORDER
BRIGHTCAT
CIRCLECLOSE #
*DATA*DEF FN
DRAWERASE
FLASH*FN
FORMATINK
INVERSEMERGE
MOVEOPEN #
OUTOVER
PAPERPOINT
*READRESTORE
*SCREEN$VERIFY
VAL$

Extra commands on T-2068 & TS 2068 only

FREE
ON ERR
SOUND
STICK

Table 5 — Character sets on Group 1 and 2

CHR$Group 1 codeGroup 2 codeCHR$Group 1 codeGroup 2 code
A3865V5986
B3966W6087
C4067X6188
D4168Y6289
E4269Z6390
F437002848
G447112949
H457223050
I467333151
J477443252
K487553353
L497663454
M507773555
N517883656
O527993757
P5380SPACE032
Q5481
R5582
S5683
T5784
U5885

Products

 

Media

 

Image Gallery

Source Code

Scroll to Top