--- title: "Programming Tips for Timex Sinclair Computers" type: "article" slug: "programming-tips-for-timex-sinclair-computers" url: "http://localhost/article/programming-tips-for-timex-sinclair-computers/" markdown_url: "http://localhost/article/programming-tips-for-timex-sinclair-computers.md" published_at: "2022-10-07T12:28:05+00:00" modified_at: "2026-07-29T07:43:25+00:00" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "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…" category: - name: "T. S. S. Newsnotes" slug: "t-s-s-newsnotes" taxonomy: "category" url: "http://localhost/category/periodicals/t-s-s-newsnotes/" post_tag: - name: "Best of Timex/Sinclair 2068 Articles and Documents" slug: "ts2068best" taxonomy: "post_tag" url: "http://localhost/tag/ts2068best/" - name: "Reference" slug: "reference" taxonomy: "post_tag" url: "http://localhost/tag/reference/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" indiv: - name: "Don Barnard" slug: "barnard-don" taxonomy: "indiv" url: "http://localhost/indiv/barnard-don/" publication_r: id: 23153 title: "T. S. S. Newsnotes" type: "periodical" url: "http://localhost/periodical/t-s-s-newsnotes/" authors_r: - name: "Don Barnard" slug: "barnard-don" taxonomy: "indiv" url: "http://localhost/indiv/barnard-don/" volume: "1" issue: "10-11" issues_articles: - id: 40246 title: "T. S. S. Newsnotes v1 n10-11" type: "issue" url: "http://localhost/issue/t-s-s-newsnotes-v1-n10-11/" pages: "4-7" pubdate: "July - August 1985" archive_link: false --- # Programming Tips for Timex Sinclair Computers 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 A | Column B | | --- | --- | | `10 FOR N= SGN PI TO INT PI` | `10 FOR N=1 TO 3` | | `20 PRINT AT NOT PI, SGN PI;` | `20 PRINT AT 0,1;` | | `30 LET A=INT EXP PI` | `30 LET A=23` | | `40 POKE VAL "3e4",NOT PI` | `40 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. | SCROLLING | `POKE 23692,#` | (#=any number from 1 to 255) | | --- | --- | --- | | KEYBOARD CLICK | `POKE 23609,#` | (#=any number from 1 to 255) | | KEY RETURN | `POKE 23561,#` | (#=any number from 1 to 35) | | KEY RETURN | `POKE 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 1 | Group 2 | | --- | --- | | `SCROLL` | `RAND USR 3582` | A variable may be used to select this option. e.g. `LET T=USR 3582` | Group 1 | Group 2 | | --- | --- | | `PLOT X,Y` | `PRINT AT 21-Y/2,X/2;` | Print the appropriate quarter square graphic character. | Group 1 | Group 2 | | --- | --- | | `UNPLOT X,Y` | `PRINT 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 2 | Group 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 2 | Group 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 2 | Group 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 2 | Group 1 | | --- | --- | | `PLOT` | `No 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 | ATTR | BEEP | | --- | --- | | *BIN | BORDER | | BRIGHT | CAT | | CIRCLE | CLOSE # | | *DATA | *DEF FN | | DRAW | ERASE | | FLASH | *FN | | FORMAT | INK | | INVERSE | MERGE | | MOVE | OPEN # | | OUT | OVER | | PAPER | POINT | | *READ | RESTORE | | *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 code | Group 2 code | CHR$ | Group 1 code | Group 2 code | | --- | --- | --- | --- | --- | --- | | A | 38 | 65 | V | 59 | 86 | | B | 39 | 66 | W | 60 | 87 | | C | 40 | 67 | X | 61 | 88 | | D | 41 | 68 | Y | 62 | 89 | | E | 42 | 69 | Z | 63 | 90 | | F | 43 | 70 | 0 | 28 | 48 | | G | 44 | 71 | 1 | 29 | 49 | | H | 45 | 72 | 2 | 30 | 50 | | I | 46 | 73 | 3 | 31 | 51 | | J | 47 | 74 | 4 | 32 | 52 | | K | 48 | 75 | 5 | 33 | 53 | | L | 49 | 76 | 6 | 34 | 54 | | M | 50 | 77 | 7 | 35 | 55 | | N | 51 | 78 | 8 | 36 | 56 | | O | 52 | 79 | 9 | 37 | 57 | | P | 53 | 80 | SPACE | 0 | 32 | | Q | 54 | 81 | | | | | R | 55 | 82 | | | | | S | 56 | 83 | | | | | T | 57 | 84 | | | | | U | 58 | 85 | | | |