Morse Master
- Type
- Education
- Category
- Morse code trainer (text file to Morse sound)
- Author
- Patrick Bass
- Published in
- Antic, December 1987 (Vol. 6, No. 8), "Morse Code Trainer"
- Year
- 1987
- Language
- Atari BASIC
- Requirements
- Any Atari 8-bit, Atari BASIC, disk drive and a text file to play
- Tags
- antic, morse-code, ham-radio, sound, education, disk-files, atari-basic
About the program
Patrick Bass, Antic's ST Resource technical editor, admitted in December 1987 that Morse code was "about as hip as hula-hoops". He noted that the FCC had recently dropped the Morse requirement for a ham licence, but he thought it still worth learning, not least because aviation radio beacons identify themselves in Morse. He took his method from John Alexander, a World War II radioman he had worked with. "You don't listen for dahs or dits, you listen for the sound of the letter," Alexander had told him. The Army put recruits in a room with recorded Morse and the matching text, day after day.
Morse Master does the same. It reads a text file from disk and sounds every letter in Morse code, printing each letter as it plays, so you read along while you listen. The article also had a GFA BASIC version for the ST. For the opposite job, Bass pointed readers to "Morse Code Receiver" in the November 1985 Antic.
What you need
Any Atari 8-bit with Atari BASIC and a disk drive, plus a text file to play. Any ATASCII text will do: an AtariWriter or text-editor file, or one made in BASIC:
OPEN #1,8,0,"D:LESSON":PRINT #1;"THE QUICK BROWN FOX":CLOSE #1
Typing it in
The only special characters are in line 230: an inverse prompt ({inv}…{/inv}, the Atari key) and four {LEFT} cursor moves (ESC, then CTRL-left arrow each time). Bass wrote the program in a self-documenting style, with named constants such as TRUE, FALSE, KEYBOARD, DISK and READ in lines 160–174. Lines 210 and 290 hide a joke. In the original program, the NOT in STEP NOT is not the operator but a variable called NOT that's never assigned, so it's zero. The listing here calls it NUL instead (see Changes from the published listing). Either way it's STEP 0, which makes both FOR loops run forever: they end only when the program changes LOOP or the end of the file triggers the TRAP.
How to use it
RUN it and type the file name at the prompt, including the drive (for example D1:LESSON). The "D1:" on screen is only a reminder and is overwritten as you type. The program prints and sounds each letter, skipping digits, punctuation and spaces. At the end it asks "Read another File?"; press N to stop.
How it works
- Morse as digits. The DATA in lines 188–193 hold a four-character pattern for each letter A–Z:
0for a dot,1for a dash,2for "nothing". So A is0122(·–) and Q is1101(––·–). Lines 182–186 pack them intoM$five characters apart, and line 510 finds a letter's slice with(CHARACTER-65)*5. - Sound. Line 610 turns on voice 1 as a pure tone, and the delay loop holds it for 10 counts for a dot or 25 for a dash, followed by a short gap of 15 (lines 600–640).
- Case. Line 452 folds lower-case letters into upper case by subtracting 32.
Variations to try
The program puts no extra gap between letters or words, so the letters run together, as you can see on the screen. Add 575 FOR D=0 TO 40:NEXT D for a letter gap, and 456 IF CH=32 THEN FOR D=0 TO 100:NEXT D for a longer pause between words. Change the 10 and 25 in lines 550–560 to set the speed, and the first 10 in line 610 to change the pitch.
Changes from the published listing
One change. Atari BASIC's backtracking parser lets a variable be called NOT, but most other BASICs (including the Altirra BASIC replacement built into many emulators) only see the operator and reject lines 210 and 290. The variable is renamed NUL: same length, still never assigned, so it's still 0 and the program behaves exactly as published.
| Line | As published | Now |
|---|---|---|
| 210 | STEP NOT |
STEP NUL |
| 290 | STEP NOT |
STEP NUL |
Listing
100 REM
110 REM ATARI BASIC MORSE MASTER
120 REM (c) 1987 ANTIC PUBLISHING
130 REM Written by Patrick Bass
140 REM Version 090287
150 REM
152 REM - - - - - - - - - - - - - - -
160 LET TRUE=1:LET OFF=40000
170 LET FALSE= NOT TRUE
171 LET EOF=340
172 LET KEYBOARD=1:LET DISK=2
174 LET READ=4:LET WRITE=8
176 OPEN #KEYBOARD,READ,0,"K:"
180 DIM BELL$(1),X$(40),FILENAME$(40)
181 DIM M$(1000),Z$(100)
182 FOR LETTER=0 TO 26
183 READ X$
184 LET INDEX=(LETTER*5)
185 LET M$(INDEX+1)=X$
186 NEXT LETTER
187 REM
188 DATA 0122,1000,1010,1002,0222
189 DATA 0010,1102,0000,0022,0111
190 DATA 1012,0100,1122,1022,1112
191 DATA 0110,1101,0102,0002,1222
192 DATA 0012,0001,0112,1001,1011
193 DATA 1100,END
194 REM
199 LET BELL$=CHR$(253)
200 REM
210 FOR LOOP=FALSE TO TRUE STEP NUL
220 REM
222 PRINT "{CLEAR}"
224 PRINT " MORSE MASTER!"
225 PRINT
226 TRAP EOF
230 PRINT "{inv} Filename:{/inv} D1:{LEFT}{LEFT}{LEFT}{LEFT}";
250 INPUT FILENAME$
260 OPEN #DISK,READ,0,FILENAME$
270 REM
280 TRAP EOF
290 FOR C=FALSE TO TRUE STEP NUL
300 GET #DISK,CHARACTER
310 GOSUB 450
320 NEXT C
330 REM
340 CLOSE #DISK
350 REM
352 PRINT
360 PRINT "{DOWN}{DOWN}{DOWN}{inv} Read another File? {/inv}";
370 GET #KEYBOARD,KEYSTROKE
380 LET X$=CHR$(KEYSTROKE)
390 IF X$="N" THEN LOOP=(TRUE+TRUE)
400 REM
410 NEXT LOOP
414 END
420 REM
430 REM ----------------------------
440 REM EMIT CHARACTER
450 LET CH=CHARACTER
452 IF CH>96 THEN CH=(CH-32)
454 LET CHARACTER=CH
460 LET X$=CHR$(CHARACTER)
470 LET P1=FALSE:LET P2=FALSE
480 IF X$>="A" THEN LET P1=TRUE
482 IF X$<="Z" THEN LET P2=TRUE
490 IF (P1 AND P2) THEN GOSUB 500
492 RETURN
494 REM
500 REM -----------------------------
510 LET INDEX=((CHARACTER-65)*5)
512 PRINT CHR$(CHARACTER);
520 LET X$=M$(INDEX+1,INDEX+5)
530 FOR X=1 TO 4
540 LET Z$=X$(X,X)
545 LET DELAY=0
550 IF Z$="0" THEN DELAY=10
560 IF Z$="1" THEN DELAY=25
565 IF DELAY THEN GOSUB 600
570 NEXT X
580 RETURN
590 REM
600 REM -----------------------------
610 SOUND 1,10,10,15
620 FOR D=0 TO DELAY:NEXT D
630 SOUND 1,0,0,0
640 FOR D=0 TO 15:NEXT D
690 RETURN
Download
The original program from the Antic disk, to LOAD or ENTER instead of typing it: MORSE8.BAS.
Credits
- Program listing: Morse Master — program listing (Antic, December 1987 (Vol. 6, No. 8), "Morse Code Trainer") — Patrick Bass
- Picture: Morse Master keying out a text file (here its own listing): letters appear as they sound, with no spaces. — Patrick Bass (program); screenshot by the site
- ANTIC Vol. 6 No. 8 (December 1987) — Morse Code Trainer, by Patrick Bass — Patrick Bass, 1987
- Antic Software Archive — December 1987 - Vol. 6 No. 8 disk: MORSE8.BAS — AtariMagazines.com (Kevin Savetz), 1987
