for the TS1000 (2K or 16K RAM) Lower-case letters on the Timex/Sinclair 2040!
The Timex/Sinclair 2040 personal printer is really a super printer, especially for the price. It turns out those program listings so easily and quickly that it’s almost better than looking at the listing on the screen. When I bought my printer, however, I was hoping that I would be able to do more than that.
It’s true you can COPY and LPRINT anything that can be shown on the screen, but that still leaves much to be desired. At times, we would all like to have lower-case letters, an exclamation point, an apostrophe, or perhaps other more specialized characters. I don’t like to feel like my printer is that inferior to the more expensive printers. So I developed a program called SUPERPRINTER. And in three easy steps I will show you how to make your own Timex/Sinclair 2040 print upper-case and lower-case letters.
Enter the program as follows:
1) Type in Listing 1. Press RUN and ENTER.
2) In FAST mode, type in Listing 2. Press RUN and ENTER. At the prompt, ENTER each number in Figure 1, going by columns. Be sure to note that the twelfth number is 35 for the 2K version although it is 63 for 16K use. As you ENTER each number, it is displayed on the screen along with the address it is being POKEd into. If you make a mistake write down the address and POKE the correct number into that address after the program is done. When the last number has been ENTERed the screen will go blank and an inverse K cursor will appear. If you had any errors, correct them now.
3) In FAST mode again, type in Listing 3. Your program is now complete. To SAVE it for future use, press RUN 9800 and ENTER and start your tape recorder recording. Make sure you get a good SAVE or two so that you don’t ever have to ENTER all those numbers again. Whenever you want to LOAD the program you must first RUN the appropriate program from Listing 1 and then LOAD “SUPERPRINTER”.
You are now ready to use the program and do some SUPERPRINTing! SUPERPRINTER can be used from immediate mode or from within a program that you add between lines 5 and 9700. To COPY the screen with SUPERPRINTER you simply ENTER the command GOSUB 9710. If you want to COPY a number of lines other than the usual 22, then first LET NUM= the number of lines you want (from 1 to 24) and then GOSUB 9700. The number of lines COPYed will stay the same until you change them again. To LPRINT a string with SUPERPRINTER you must first LET Z$=”the string” and then GOSUB 9730.
If you experiment with these commands you will note that GRAPHICS symbols and numbers are printed normally but all letters are printed in lower-case. For upper-case letters you must type inverse (GRAPHICS) letters. You can also use inverse 8 to print an exclamation point and inverse 9 for an apostrophe. Go ahead and try out the new power now available to you.
If you only have 2K of memory and find yourself running out of space too soon you may wish to delete lines 9800 through 9920 to make a little more room. With 16K you should leave these lines in so that if you write an additional program that you want to SAVE you can RUN 9800 and SAVE the whole program, including data and machine code above RAMTOP. Remember to note that you will have to set RAMTOP correctly, by RUNning Listing 1, before reLOADing.
Figure 2 gives a sample program used with SUPERPRINTER along with the resulting printout. This demonstrates how to use the new capabilities of your printer. If you would like to understand a little more of how this all works, and maybe make some changes in the characters printed, please continue reading.
First, the reason why the LPRINT routine in the ROM can’t print lower-case letters: It sends out data to the printer which tells it whether to make each little dot black or white. For the shapes of the characters it is programmed to rely on the same dot pattern table used to store the shapes of characters displayed on the screen. There apparently was not enough room in the 8K ROM for this table to hold anything but the upper-case letters and other Sinclair characters.
Both the LPRINT routine and the dot pattern table it uses are in ROM (Read-Only Memory) so we cannot change them. We must move them to the RAM and use them there if we are going to make modifications. The program given in Listing 1 changes the system variable RAMTOP so as to make room for the ROM routine and table above the BASIC operating system area.
Lines 10 through 50 of Listing 2 move the 140-byte LPRINT routine to this new area. Lines 60 and 70 change it so that rather than automatically use the ROM dot pattern table, it jumps to a control routine at the end of it.
This 32-byte machine language routine is INPUT from Figure 1 by lines 90 and 100 of Listing 2. It determines when to use the ROM table and when to use our own table. The routine is shown in disassembled form in Figure 3. The JR REENTRY instruction at the end returns control to where the LPRINT routine was left, with the H register properly loaded. The H register must hold half the value of the most significant byte of the address the table starts at.
Listing 1. Setting RAMTOP.
For 16K machine:
10 POKE 16388,84
20 POKE 16389,125
30 NEW
For 2K machine:
10 POKE 16388,84
20 POKE 16389,69
30 NEW
Listing 2. ENTERing data.
10 LET A=PEEK 16388+256*PEEK 16389
20 FOR N=2153 TO 2292
30 POKE A,PEEK N
40 LET A=A+1
50 NEXT N
60 POKE A-77,24
70 POKE A-76,75
80 PRINT ,,"ENTER EACH NUMBER IN FIGURE 1."
90 LET B=31
100 GOSUB 1000
110 LET A=A+320
120 LET B=223
130 GOSUB 1000
140 NEW
1000 FOR N=A TO A+B
1010 INPUT C
1020 SCROLL
1030 PRINT N,C
1040 POKE N,C
1050 NEXT N
1060 RETURN
Listing 3. SAVE and use program.
5 LET RT=PEEK 16388+256*PEEK 16389
9699 STOP
9700 POKE RT+1,NUM
9710 RAND USR RT
9720 RETURN
9730 FOR N=16444 TO 16475-(32-LEN Z$)*(LEN Z$<33)
9740 POKE N,CODE Z$(N-16443)
9750 NEXT N
9760 RAND USR (RT+8)
9770 IF LEN Z$<33 THEN RETURN
9780 LET Z$=Z$(33 TO )
9790 GOTO 9730
9800 LET A$=""
9810 LET B=PEEK 16388+256*PEEK 16389
9820 FOR N=B TO B+683
9830 LET A$=A$+CHR$ PEEK N
9840 NEXT N
9850 SAVE "SUPERPRINTER"
9860 IF B=PEEK 16388+256*PEEK 16389 THEN GOTO 9890
9870 PRINT ,,"RAMTOP WAS NOT SET CORRECTLY."
9880 STOP
9890 FOR N=B TO B+683
9900 POKE N,CODE A$(N-B+1)
9910 NEXT N
9920 RUN
Listing 4. Char. designing aid.
9000 PRINT ,,"ENTER CHARACTER NUMBER(0-63)-";
9010 INPUT A
9020 IF A>63 OR A<0 THEN GOTO 9010
9030 PRINT A;AT 4,11;"▒▒▒▒▒▒▒▒▒▒";AT 13,11;"▒▒▒▒▒▒▒▒▒▒"
9040 FOR N=5 TO 12
9050 PRINT AT N,11;"▒ ▒"
9060 NEXT N
9070 DIM A(8,8)
9080 LET B=1
9090 LET C=B
9100 LET D=128
9110 SLOW
9120 PRINT AT 4+B,11+C;CHR$ D;AT 4+B,11+C;CHR$ ABS (D-128)
9130 LET E=CODE INKEY$
9140 IF E<33 OR E>43 OR (E>36 AND E<41) THEN GOTO 9120
9150 IF E=43 THEN GOTO 9240
9160 IF E<37 THEN GOTO 9200
9170 LET D=128*(E-41)
9180 LET A(B,C)=42-E
9190 GOTO 9120
9200 LET C=C+(E=36 AND C<8)-(E=33 AND C>1)
9210 LET B=B+(E=34 AND B<8)-(E=35 AND B>1)
9220 LET D=128*(1-A(B,C))
9230 GOTO 9120
9240 LET E=A*8+32255
9250 FAST
9260 FOR B=1 TO 8
9270 LET A=0
9280 FOR C=1 TO 8
9290 LET A=A+A(B,C)*2**(8-C)
9300 NEXT C
9310 POKE E+B,A
9320 NEXT B
The remainder of the BASIC program in Listing 2 is used to INPUT the rest of the data from Figure 1. This data determines the shape of the new characters.
The main SUPERPRINTER program in Listing 3 is pretty straightforward. Lines 9800 and on are used only when SAVEing the program. The data and machine code above RAMTOP is loaded into A$ so that it will be SAVEd too. When the program later is LOADed it will be POKEd back into the proper locations. Line 5 must be RUN before the rest of the program will work. Lines 9730 to 9790 may look a little complicated but all they do is load Z$ into the LPRINT buffer at addresses 16444 to 16475 and LPRINT it one line at a time.
If you’ve been itching to design some characters of your own the time has come. Figure 4 shows a sample portion of the dot pattern table. The formula is given for finding where each character shape starts. The pattern is visible in the binary version. You can design your characters on paper and POKE the values in directly if you understand this technique. For those with 16K, however, there is a much easier way to design your own characters. Just add the lines in Listing 4 to your existing SUPERPRINTER program.
When you start this program, using RUN or RUN 9000, you will be prompted for a character code between 0 and 63, inclusive. Refer to your BASIC manual for the character codes. Codes 36 through 63 are already used but you can of course change them. Codes 11 through 35 are best to use for additional characters. These will be LPRINTed when the GRAPHICS inverse of that character is sent to SUPERPRINTER.
Use the unshifted arrow keys (5 through 8) to move the flashing cursor. Press “D” to draw a pixel and “E” to erase one. Press “F” when finished. The program will then POKE the correct data into the proper locations and STOP at line 9699. After designing a character with this program, you can COPY the screen for a hard copy of your design or you can RUN or RUN 9000 to design another character.
If you decide that you want to print only your own characters without switching back and forth between upper-case and lower-case letters then you should bypass the machine language control routine. To do this you need to POKE RAMTOP (RT) +63, 38. Also POKE RT +64, 63(or 35 for 2K). Now only the characters you have designed will be printed and not the regular Sinclair characters.
With a little imagination I’m sure you will find even more exciting ways to use this new power of your printer. Complete high-resolution printouts can be done. The alphabet of a different language could be printed. Characters could be printed upside-down or sideways. You can print your own graph paper for special uses. And you can also print very nice graphs. Or you may also need some special math or science symbols. A real classy touch at the end of a letter is to have the printer print your signature just like you would sign it.
Whether you go on to design your own characters and special uses for SUPERPRINTER or use the upper-case/lower-case capability for word processing I’m sure you will have fun making the most out of that amazing little black box called a Timex/Sinclair 2040. Let me know of any other uses you can dream up for SUPERPRINTER.
If you don’t feel like typing in the programs in this article, the author will send you a copy on tape for $6, postpaid, in the United States, or $9 foreign.
James A. Webster
410 Fremont Street
Laredo, Texas 78040
Figure 1. Data to be ENTERed.
245 0 0 0 0 0 0 0 121 16 0 0 64 0 0 0 7 16 60 62 68 60 62 68 56 16 66 66 72 66 64 84 9 16 64 66 80 66 60 84 31 0 66 62 104 66 2 56 254 16 60 2 68 60 60 40 38 0 0 60 0 0 0 0 56 0 0 0 0 0 0 0 17 16 2 64 112 0 32 0 38 16 2 64 16 124 32 66 63* 32 62 124 16 66 124 36 24 0 66 66 16 66 32 24 15 0 66 66 16 124 32 36 203 0 62 66 124 64 24 66 63 0 0 0 0 64 0 0 79 0 0 0 0 0 0 0 254 0 0 16 0 0 0 0 38 60 60 0 92 62 66 68 48 2 66 48 42 66 66 40 6 62 124 16 42 66 66 16 254 66 64 16 42 62 70 16 11 62 62 124 42 2 58 16 48 0 0 0 0 2 0 96 241 0 0 0 0 0 0 0 203 64 12 0 0 0 0 0 249 64 18 2 92 92 68 126 38 124 16 0 34 34 68 4 15 66 124 2 34 32 68 24 241 66 16 2 34 32 40 32 24 124 16 98 34 32 16 126 149 0 0 60 0 0 0 0 * Should be 35 for 2K version.
Figure 2. SUPERPRINTER example.
5 LET RT=PEEK 16388+256*PEEK 16389
10 LET Z$="[inverse T]HIS IS A DEMONSTRATION OF THE [inverse SUPERPRINTER] PROGRAM WITH THE [inverse T]IMEX-[inverse S]INCLAIR 2040 PRINTER:"
20 GOSUB 9730
30 PRINT ,,,,
40 FOR N=0 TO 63
50 PRINT CHR$ (N+128);CHR$ N;" ";
60 NEXT N
70 LET NUM=8
80 GOSUB 9700
9699 STOP

Figure 3. M.L. control routine.
ADDR DEC. ASSEMBLY RT+: CODE NAME LANGUAGE ====================================== 140 245 CONTROL PUSH AF 141 121 LD A,C 142 7 RLCA 143 56,9 JR C INVERSE 145 31 RRA 146 254,38 CP 38d 148 56,17 JR C NORMAL 150 38,63* OWN CH LD H, 63d 152 24,15 JR DONE 154 203,63 INVERSE SRL A 156 79 LD C,A 157 254,38 CP 38d 159 48,6 JR NC NORMAL 161 254,11 CP 11d 163 48,241 JR NC OWN CH 165 203,249 SET 7,C 167 38,15 NORMAL LD H, 15d 169 241 DONE POP AF 170 24,149 JR REENTRY * 35 for 2K version.
Figure 4. Dot pattern table.
8*38(CODE for "A")+172+RAMTOP=
A START=18224(2K) or 32560(16K)
Dec. Binary
A START 0 00000000
0 00000000
60 00111100
2 00000010
62 00111110
66 01000010
62 00111110
0 00000000
B START ...

Products
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.