Morse Code Trainer
For your o- - o- -o- oo * 8-bit and ST
* (Atari)
By PATRICK BASS ST Resource Technical Editor
Anachronism.
In today's world of fast personal computers and ASCII standards, Morse code is about as hip as hula-hoops, mood rings or the Edsel. Unless you inhabit the short-wave radio airways it's possible you may never hear Morse code, unless it's the famous "SOS". Since the FCC has just recently allowed the use of radio-modems, and dropped the Morse requirement for a HAM license, Morse code may slip further into the mists of obscurity.
Unless you help to keep it alive. Learning Morse code is not that difficult, and comes in handy in the most extrordinary ways. For example, if you ever learn to fly, you'll find the radio navigation aid beacons (VOR/ VORTAC) beep their names using Morse Code.
THE MILITARY WAY
Okay, so what's the best way to learn Morse code? I once worked with a fellow named John Alexander, who had been a radioman during World War II. He described how he learned Morse Code in the military. "Look kid, there're three ways to do things-the right way, the wrong way and the Army way," he said. "This is how they taught us. You don't listen for dahs or dits, you listen for the sound of the letter. Each one has its own unique tempo and sound." I looked confused. His cigar travelled from one side of his mouth to the other. "You see," he continued, "They put us in this room, where day in and day out we listened to a recording of a Morse code signal over and over, and read the text that came with it."
And that's how you'll learn Morse code with your Atari computer. This month we present two programs (an 8-bit version and an ST version) that will convert any text file you type in to Morse code, and play it back for you while you read the text. The Atari computer is a tireless teacher, with a perfectly repeatable "fist" to teach you Morse code. Incidentally, Antic has already published a program which will convert from Morse Code to ASCII text. Read "Morse Code Receiver" in the November 1985 issue of Antic.
UP AND RUNNING
For the Atari 8-bit computers, you'll find M0RSE8.BAS on your Antic Monthlt Disk. You may RUN this file from the menu, or load it using Atari BASIC and examine or change the code. If you have an Atari ST, you'll find the source code to MORSEI6.BAS in GFA BASIC on side B of the Antic Monthly Disk, along with MORSE16.PRG, an executable version which does not require GFA BASIC to run. You need to transfer these files over to your Atari ST using Linkline. The directions for using Linkline are in the HELP file on side B of your Antic Monthly Disk. When MORSE16.PRG is on your ST disk, simply double-click on it. You'll need to create a simple ASCII text file containing the letters, words, or phrases you want converted into Morse code. When the program gets up and running, you'll select the text file to sound out.
If you don't have the disk, you'll need to type in the programs. Listing 1 is the Atari 8-bit version of Morse Master. Listing 2 is the Atari ST version. Type in the version for your particular Atari computer. If you type in the Atari 8-bit version, pay close attention to the TYPO II codes. If they don't match the ones printed in the magazine, you may have a mistake somewhere in that line. Sorry, but at the moment, we don't have a TYPO program for GFA BASIC, and while GFA will syntax-check each line as it is typed in, you'll still need to check variable names closely.
PROGRAM BREAKDOWN
Let's examine Listing 2 closely to determine how the program operates. The top four lines contain the title and author information. Right below that we encounter the main loop of the program. Here, we Initialize the program, then Select a file, and if the file actually exists, we Emit the file. When the entire file has been sounded out, an alert box will pop up, asking if you want to listen to another file. If you don't, click on [No], and the program will drop back to the desktop.
Initialize
First, save space for the Morse code translations which are saved inside Data statements. Next, we need to create a place to hold our text file, so Dim a 100K text buffer and find out where in memory it is. Below that, read all the Morse translation strings and place them inside an array, so we can index to them directly according to the value of the letter we want to reproduce. Next, test to see if we're in low resolution, and if we are, present an alert box and ask to be changed to medium resolution, otherwise assign various small variables their initial values, and return.
Emit_file
In here, we first clear the screen, then remind you which file is being read, and remind you to press any key for an early exit. Next, we advance character by character through the text buffer, sounding out every alphabetic character there is, skipping over punctuation and numbers. Eventually, we'll either reach the end of the file, or press a mouse button or any key, and this routine will end, and return.
Emit_character
This is the routine which actuall creates the Morse code sound. According to the value of the character passed to it, this routine will index to the proper Morse code translation string, and advance through it, sounding out the individual dots and dashes for that particular character.
Select_file
Here is where we select which file to access and read in. When this routine is executed, the familiar File Selector Box is presented onscreen, and waits while you select a filename. If the filename you select actually does exist on the disk, it is read into the text buffer created earlier, and the routine exits. Otherwise, you'll warned no such file was found, and be given the chance to select another.
CARE AND FEEDING
The perfect way for you to use Morse Code Trainer would be to type in your example text, sit back and listen carefully. With luck and some patience, you'll be "ditting" and "dahhing" in no time.
Listing:MORSE8.BAS Download