Skip to content

Typewriter Simulation Program for the Atari

Atari Computer > Electric Typewriter

Atari 800XL home computer with built-in keyboard and function keys on the right side. Ask ChatGPT

When my daughter came home from school and announced that she had to have an electric typewriter to practice her typing class assignments on, I said “NO WAY“; at least while I have my faithful ATARI around!!! I proceeded to endeavor to make a simple program to mimic an electric typewriter. 

The BASIC program works like this:  

Get an Input from the keyboard. Analyze the Input and Put it on the screen, or if the Input is a RETURN; then print the line (to a printer). Here is the program listing:

					10 PAGE=80:MARGIN=5:REM PAGE SIZE AND MARGIN WIDTH 
20 C255=255:C764=764:C155=155:C1=1:C2=2:C3=3 
30 PAGE=PAGE-C2*MARGIN:BELL=PAGE-4 
40 TRAP 100:OPEN #C1,4,0,"K:":OPEN #C2,8,0,"E:":OPEN #C3,8,0,"P:" 
50 PUT #C3,18:PUT #C3,C155 
60 DIM A$(PAGE),BL$(MARGIN) 
70 BL$=" ":BL$(MARGIN)=BL$:BL$(C2)=BL$ 
80 ? " *** Typewriter Simulation ***":? "   by Lee Gassaway * 10/04/85 *" 
100 POKE C764,C255:LOC=1:? 
110 A$=" ":A$(PAGE)=A$:A$(C2)=A$ 
200 REM INPUT FROM KEYBOARD 
205 GET #C1,X:IF X=C155 THEN LPRINT BL$;A$:PUT #C2,X:POKE C764,C255:GOTO 100 
210 IF LOC>=PAGE THEN PUT #C2,253:GOTO 200 
215 IF X=30 THEN LOC=LOC-(PEEK(85)/2):GOTO 280 
220 IF X=31 THEN LOC=LOC+((LOC<PAGE) AND (PEEK(85)<39)):GOTO 280 
230 IF X=28 AND LOC>38 THEN LOC=LOC-38:GOTO 280 
235 IF X=28 AND LOC<39 THEN X=253:GOTO 280 
240 IF X=29 AND LOC<39 THEN LOC=LOC+38:GOTO 280 
245 IF X=29 AND LOC>38 THEN X=253:GOTO 280 
250 IF X=126 THEN A$(LOC,LOC)="  ":LOC=LOC-(LOC>1):GOTO 280 
260 A$(LOC,LOC)=CHR$(X) 
270 LOC=LOC+1 
280 PUT #C2,X 
290 IF LOC=BELL THEN PUT #C2,253 
300 GOTO 200 
				

Now a Detailed Explanation: 

Line 10 — Sets the maximum line length to 80 (you can change PAGE to any other number you wish, i.e., 40 or 132). You will then also have to adjust the printer setup code in line 50 for your selected printer width. The margin is the number of blank spaces from both sides of the page between which the text will be printed. MARGIN=5 means there is a margin 5 characters wide on the left and at least 5 characters on the right. 

Line 30 — Sets the BELL buzzer to 4 spaces before the end of the line. 

Line 40 — In this line we make the Atari Computer modify itself so that we can control things. First we OPEN channel #1 to GET (4) what is coming from the KEYBOARD (“K:”). Second we OPEN channel #2 to PUT (8) what we want to the screen EDITOR (“E:”). This allows us to PUT cursor control commands to the screen without having to worry about too many details. Third we OPEN channel #3 to PUT things to the PRINTER (“P:”). 

Line 50 — We PUT character #18 followed by #155 (RETURN) to initialize my EPSON printer to 80 column mode. (Editor’s Note: If you don’t have an EPSON, you may have to change the 18 to something else, or maybe just remove line 50 if your printer’s default mode is 80 column. This is also where you would change your printer to 40 or 132 column mode if you make the changes mentioned in the explanation of line 10.) 

Line 60 — DIMensions the STRING variables to what we need for our page size and margin selection. 

Line 70 — Fills BL$ with blanks. 

Line 80 — Displays the program title on the screen. 

Line 100 — Prepares the Keyboard so we are ready for the first INPUT of the line. 

Line 110 — Fills A$ with blanks. 

Line 205 — GET’s the input from the KEYBOARD. IF the input was RETURN, THEN print the line BL$(margin) followed by line A$(page); then PUT a RETURN to the SCREEN and goto the start of the next line (Line 100). 

Lines 210-245 — Test the input to see if it is a command which would put the cursor outside of the line(page) size. IF the input does, then RING the BELL (#253). 

Line 250 — Tests for the DELETE BACK SPACE key being pressed. 

Line 260 — Place the output into the line at the current location. 

Line 270 — Move to the next location. 

Line 280 — PUT the INPUT on the SCREEN. 

Line 290 — IF the LOCation is 4 from the end of the line, then RING the BELL. 

Line 300 — GOTO GET the next INPUT. 

PHOTO CREDITS:
  • Photo of vintage Atari keyboard from Games Electronics R Us. Used under Fair Use for the purpose of education and historical reference.