Semaphore

Type
Education
Category
Semaphore flag-signalling trainer
Author
Howie Wishart
Published in
Antic, December 1988 (Vol. 7, No. 8), runner-up in the Super 8-Bit Contest
Year
1988
Language
Atari BASIC
Requirements
16K RAM, Atari BASIC; printer optional
A dark green stick-figure signalman holding one white flag straight up and the other straight out to the side, above the words TYPE A LETTER, TYPE 'ESC' TO QUIT and a large letter J

About the program

Morse trainers were common, but Howie Wishart had never seen a program for practising semaphore, the flag code in which each letter is shown by holding the two arms at one of eight angles. As a former signalman in the Canadian Navy, he had taught semaphore aboard ship and in classrooms. A primitive version of this program had been his first serious attempt at programming, after he bought an 800XL in 1985. The finished Semaphore was a runner-up in Antic's Super 8-Bit Contest and appeared in the December 1988 "Best of 1988" issue. The prize was an ICD R-Time 8 cartridge and the SpartaDOS Construction Set.

A little man stands on the screen and signals with two flags while the letter appears below him in large GRAPHICS 2 text, or stays hidden if you want to test yourself. Wishart's article also explained the conventions. Both arms down and crossed means a space. EEEEEEEE means "error". You get the other operator's attention by flapping your arms like a bird, and they reply with R ("Roger") or a question mark. Numbers are spelled out, punctuation is sent as letter groups the same as in Morse (AAA for a full stop, MIM for a comma, IMI for a question mark, and so on), and AR ends a message. NATO navies required at least 15 words per minute, and good operators managed over 30.

Typing it in

Line 4 says do not renumber, for a good reason (see below). Apart from that it's mostly plain BASIC. The menus use inverse digits ({inv}…{/inv}, Atari key), and {CLEAR} and {DOWN} are ESC followed by SHIFT-CLEAR or CTRL-down arrow. The flag and arm shapes are DATA in lines 6100–6230. The ten practice messages from line 7000 are Shakespeare (Portia's "quality of mercy", Mark Antony, the witches, Romeo, Hamlet three times, Puck and Shylock) plus Churchill's "We shall fight on the beaches". The disk version has no TYPO II codes.

How to use it

The main menu offers:

  1. and 2. Send: type any letter A–Z and the man signals it, with the letter shown or hidden. ESC returns to the menu.
  2. and 4. Receive message: a random one of the ten texts, sent after a "flap" call-up.
  3. and 6. Receive coded groups: ten random five-letter groups, the beginner's test.

You choose a speed from 10 to 30 words per minute. Afterwards you can show the text on screen or print it to check what you read. Wishart's standard for qualifying at a speed was three tests in a row with no more than two errors each.

How it works

  • A string on top of player memory. PM$ must be the first string DIMmed (line 6000). Line 5020 rewrites its entry in BASIC's variable value table (the table at the address in locations 134–135) so that its data offset points into player-missile memory. After that, assigning part of PM$, such as PM$(168,183)=A$, redraws an arm instantly, with no POKE loops. This is the same "equivalencing" trick Doug White wrote about two months later in Sound Equivalence.
  • Letters are line numbers. Lines 65–90 each draw one letter's pair of arm positions, and 65–90 are the ATASCII codes of A–Z. To send a character, line 1050 simply does GOSUB ASC(T$(X,X)), and a space (code 32) runs line 32, which lowers both flags. Hence "do not renumber".
  • The figure. Player 3 is the man; players 0, 1 and 2 hold the arm and flag pieces to his right, in front of him and to his left. Line 5060 walks him on from the left.
  • Timing by the clock. Rather than FOR/NEXT delays, the program pokes 0 into location 20 (the jiffy clock) and waits until it passes D, which line 3530 sets from your chosen words per minute. Wishart pointed out that it therefore runs at the same speed in Atari BASIC and in BASIC XL. X=1^1^1^1 in line 95 is a deliberate short delay for the error buzz.

Variations to try

Add your own messages from line 7100 onward in the same format (a count, then that many DATA strings), and change the *10 in line 3550 to the new number of messages. Wishart thought the same player technique could teach the sign-language alphabet.

Listing

1 REM SEMAPHORE
2 REM BY HOWIE WISHART
3 REM (c)1988, ANTIC PUBLISHING
4 REM DO NOT RENUMBER THIS PROGRAM!
5 GOTO 6000
32 PM$(296,309)=S$:RETURN
50 PM$(168,183)=A$:RETURN
51 PM$(166,173)=B$:RETURN
52 PM$(150,165)=C$:RETURN
53 PM$(270,293)=DL$:RETURN
54 PM$(270,293)=DR$:RETURN
55 PM$(406,421)=E$:RETURN
56 PM$(422,429)=F$:RETURN
57 PM$(424,439)=G$:RETURN
60 PM$(296,309)=SL$:RETURN
61 PM$(296,309)=SR$:RETURN
65 GOSUB 50:GOSUB 60:RETURN
66 GOSUB 51:GOSUB 60:RETURN
67 GOSUB 52:GOSUB 60:RETURN
68 GOSUB 53:GOSUB 61:RETURN
69 GOSUB 55:GOSUB 61:RETURN
70 GOSUB 56:GOSUB 61:RETURN
71 GOSUB 57:GOSUB 61:RETURN
72 PM$(166,183)=H$:RETURN
73 GOSUB 50:GOSUB 52:RETURN
74 GOSUB 54:GOSUB 56:RETURN
75 GOSUB 53:GOSUB 50:RETURN
76 GOSUB 50:GOSUB 55:RETURN
77 GOSUB 50:GOSUB 56:RETURN
78 GOSUB 50:GOSUB 57:RETURN
79 GOSUB 51:GOSUB 52:RETURN
80 GOSUB 51:GOSUB 53:RETURN
81 GOSUB 51:GOSUB 55:RETURN
82 GOSUB 51:GOSUB 56:RETURN
83 GOSUB 51:GOSUB 57:RETURN
84 GOSUB 52:GOSUB 53:RETURN
85 GOSUB 52:GOSUB 55:RETURN
86 GOSUB 54:GOSUB 57:RETURN
87 GOSUB 55:GOSUB 56:RETURN
88 GOSUB 55:GOSUB 57:RETURN
89 GOSUB 52:GOSUB 56:RETURN
90 PM$(422,439)=Z$:RETURN
95 SOUND 0,60,6,8:X=1^1^1^1:SOUND 0,0,0,0:RETURN
1000 PM$(1,440)=K$:FOR X=2 TO LEN(T$):POKE 20,0
1010 IF T$(X-1,X)="  " THEN GOSUB 1100:NEXT X
1020 IF T$(X,X)<>T$(X-1,X-1) THEN 1040
1030 PM$(1,440)=K$:POKE 20,INT(D/2):GOSUB 32:POSITION 2,11:? #6;" ":GOSUB 1100:POKE 20,0
1040 PM$(1,440)=K$
1050 GOSUB ASC(T$(X,X)):POSITION 2,11:? #6;T$(X,X):GOSUB 1100:NEXT X:PM$(1,440)=K$
1060 GOSUB 32:POSITION 2,11:? #6;" ":D=D*3:GOSUB 1100
1070 FOR X=120 TO 255:POKE 53251,X:POKE 53249,X:NEXT X:POKE 53277,0:GOTO 3800
1100 IF PEEK(20)>D THEN RETURN
1101 GOTO 1100
2000 CLOSE #1:OPEN #1,4,0,"K:":T$=" ":GOTO 5000
2010 POSITION 0,7:? #6;"   type a letter":POSITION 0,9:? #6;" type 'esc' to quit"
2020 GET #1,X:IF X=27 THEN 2100
2030 T$=CHR$(X):IF T$<"A" OR T$>"Z" THEN T$=" "
2040 PM$(1,440)=K$:GOSUB ASC(T$):POSITION 2,11:? #6;T$:GOTO 2020
2100 CLOSE #1:PM$(1,440)=K$:GOSUB 32:POSITION 2,11:? #6;" ":FOR X=120 TO 255:POKE 53251,X:POKE 53249,X:NEXT X
2110 POKE 53277,0
3000 POKE 53248,255:POKE 53250,255:? "{CLEAR}{DOWN}         {inv}DO YOU WANT TO:{/inv}{DOWN}{DOWN}{DOWN}"
3010 ? "{inv}1{/inv}. SEND (TEXT VISIBLE){DOWN}":? "{inv}2{/inv}. SEND (TEXT NOT VISIBLE){DOWN}":? "{inv}3{/inv}. RECEIVE MESSAGE (TEXT VISIBLE){DOWN}"
3020 ? "{inv}4{/inv}. RECEIVE MESSAGE (TEXT NOT VISIBLE){DOWN}"
3030 ? "{inv}5{/inv}. RECEIVE CODED GROUPS (TEXT VISIBLE)":? "{inv}6{/inv}. RECEIVE CODED GROUPS (TEXT NOT        VISIBLE){DOWN}"
3040 ? "{inv}7{/inv}. QUIT{DOWN}{DOWN}{DOWN}":? "   CHOOSE AN OPTION (1 TO 7)";
3050 CLOSE #1:OPEN #1,4,0,"K:":GET #1,X:CLOSE #1:OP=X-48:IF OP<1 OR OP>7 THEN GOSUB 95:GOTO 3000
3060 IF OP=7 THEN GRAPHICS 0:END
3070 T$="":IF OP<3 THEN 2000
3500 ? "{CLEAR}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{inv}CHOOSE YOUR SPEED (WORDS PER MINUTE){/inv}"
3510 ? "{DOWN}{DOWN}{DOWN}{DOWN} {inv}1{/inv}=10  {inv}2{/inv}=15  {inv}3{/inv}=18  {inv}4{/inv}=20  {inv}5{/inv}=25  {inv}6{/inv}=30{DOWN}{DOWN}{DOWN}{DOWN}":? "     CHOOSE AN OPTION (1 TO 6)";
3520 CLOSE #1:OPEN #1,4,0,"K:":GET #1,X:CLOSE #1:X=X-48:IF X<1 OR X>6 THEN GOSUB 95:GOTO 3500
3530 D=(X=1)*60+(X=2)*39+(X=3)*33+(X=4)*30+(X=5)*23+(X=6)*18:GRAPHICS 18:POSITION 2,4
3540 ? #6;"  STAND BY . . .":FOR X=1 TO 500:NEXT X:IF OP>4 THEN 4000
3550 EXNR=INT(RND(0)*10)+1:RESTORE 6990+10*EXNR:T$=" NRURNRURNRURNRURN    "
3560 READ C:FOR CC=1 TO C:READ P$:T$(LEN(T$)+1)=" ":T$(LEN(T$)+1)=P$:NEXT CC:T$(LEN(T$)+1)=" AR":GOTO 5000
3800 POKE 53248,255:POKE 53250,255:GRAPHICS 0
3810 ? "{DOWN}{DOWN}     {inv} DO YOU WANT TO PRINT {/inv}":? "{DOWN}{DOWN}        {inv} THIS EXERCISE? {/inv}"
3820 ? "{DOWN}{DOWN}{inv}1{/inv}. ON {inv}SCREEN{/inv}":? "{DOWN}{DOWN}{inv}2{/inv}. ON {inv}PRINTER{/inv}":? "{DOWN}{DOWN}{inv}3{/inv}. NO PRINTOUT":? "{DOWN}{DOWN}   CHOOSE AN OPTION (1, 2, OR 3)";
3830 CLOSE #1:OPEN #1,4,0,"K:":GET #1,X:CLOSE #1:IF X<49 OR X>51 THEN GOSUB 95:GOTO 3830
3840 ON X-48 GOTO 3850,3860,3000
3850 CLOSE #1:OPEN #1,8,0,"E:":GOTO 3870
3860 TRAP 3920:CLOSE #1:OPEN #1,8,0,"P:"
3870 IF OP=5 OR OP=6 THEN 3890
3880 ? #1;"EXERCISE NUMBER ";EXNR:? #1:? #1;T$(22):? #1:GOTO 3900
3890 FOR Y=24 TO 133 STEP 12:? #1;T$(Y,Y+10):NEXT Y:? #1
3900 IF X=49 THEN ? #1;"PRESS ANY KEY TO CONTINUE":CLOSE #1:OPEN #1,4,0,"K:":GET #1,X
3910 CLOSE #1:GOTO 3000
3920 CLOSE #1:TRAP 40000:? "{CLEAR}           {inv}OOPS - NO PRINTER{/inv}{DOWN}":GOSUB 95:GOTO 3810
4000 T$=" NRURNRURNRURNRURN    ":FOR X=1 TO 10:FOR Y=1 TO 5:T$(LEN(T$)+1)=" "
4010 T$(LEN(T$)+1)=CHR$(INT(RND(0)*26)+65):NEXT Y:T$(LEN(T$)+1)="  ":NEXT X:T$(LEN(T$)+1)="AR"
5000 GRAPHICS 18:V=PEEK(134)+PEEK(135)*256:A=PEEK(140)+PEEK(141)*256
5010 POKE 708,12*(OP=1 OR OP=3 OR OP=5)
5020 X=PB+384-A:H=INT(X/256):L=X-H*256:POKE V+2,L:POKE V+3,H
5030 PM$(1,440)=K$:PM$(441,539)=K$:PM$(576,640)=K$:PM$(540,575)=M$:GOSUB 32
5040 POKE 559,46:POKE 53277,3:POKE 704,12:POKE 705,12:POKE 706,12:POKE 707,212
5050 POKE 53248,104:POKE 53249,20:POKE 53250,136:POKE 53251,20:POKE 53256,1:POKE 53257,1:POKE 53258,1
5060 POKE 53259,1:FOR X=20 TO 120:POKE 53249,X:POKE 53251,X:NEXT X
5070 IF OP<3 THEN 2010
5080 GOTO 1000
6000 CLR :DIM PM$(640),A$(16),B$(8),C$(16),DR$(24),DL$(24),E$(16),F$(8),G$(16),SR$(14),SL$(14),S$(14),K$(440)
6010 DIM M$(36),H$(18),Z$(18),P$(114),T$(1000):PM$(1)=CHR$(0):PM$(640)=CHR$(0):PM$(2)=PM$:K$=PM$
6020 GRAPHICS 18:? #6:? #6:? #6:? #6;"    SEMAPHORE":? #6:? #6;"      EXERCISE":? #6:? #6;"        PROGRAM"
6030 PP=PEEK(740)-16:POKE 106,PP:POKE 54279,PP:PB=256*PP
6100 FOR X=1 TO 15 STEP 2:READ Y:A$(X,X)=CHR$(Y):A$(X+1,X+1)=CHR$(Y):NEXT X:DATA 1,2,4,8,240,240,240,240
6110 FOR X=1 TO 7 STEP 2:READ Y:B$(X,X)=CHR$(Y):B$(X+1,X+1)=CHR$(Y):NEXT X:DATA 255,240,240,240
6120 FOR X=1 TO 15 STEP 2:READ Y:C$(X,X)=CHR$(Y):C$(X+1,X+1)=CHR$(Y):NEXT X:DATA 240,240,240,240,8,4,2,1
6130 FOR X=1 TO 23 STEP 2:READ Y:DR$(X,X)=CHR$(Y):DR$(X+1,X+1)=CHR$(Y):NEXT X
6131 DATA 240,240,240,240,128,128,128,128,128,128,128,128
6140 FOR X=1 TO 23 STEP 2:READ Y:DL$(X,X)=CHR$(Y):DL$(X+1,X+1)=CHR$(Y):NEXT X:DATA 15,15,15,15,1,1,1,1,1,1,1,1
6150 FOR X=1 TO 15 STEP 2:READ Y:E$(X,X)=CHR$(Y):E$(X+1,X+1)=CHR$(Y):NEXT X:DATA 15,15,15,15,16,32,64,128
6160 FOR X=1 TO 7 STEP 2:READ Y:F$(X,X)=CHR$(Y):F$(X+1,X+1)=CHR$(Y):NEXT X:DATA 255,15,15,15
6170 FOR X=1 TO 15 STEP 2:READ Y:G$(X,X)=CHR$(Y):G$(X+1,X+1)=CHR$(Y):NEXT X:DATA 128,64,32,16,15,15,15,15
6180 FOR X=1 TO 13 STEP 2:READ Y:SR$(X,X)=CHR$(Y):SR$(X+1,X+1)=CHR$(Y):NEXT X:DATA 64,32,16,60,60,60,60
6190 FOR X=1 TO 13 STEP 2:READ Y:SL$(X,X)=CHR$(Y):SL$(X+1,X+1)=CHR$(Y):NEXT X:DATA 2,4,8,60,60,60,60
6200 FOR X=1 TO 13 STEP 2:READ Y:S$(X,X)=CHR$(Y):S$(X+1,X+1)=CHR$(Y):NEXT X:DATA 66,36,24,60,60,60,60
6210 FOR X=1 TO 35 STEP 2:READ Y:M$(X,X)=CHR$(Y):M$(X+1,X+1)=CHR$(Y):NEXT X
6211 DATA 60,90,102,60,24,255,126,126,126,126,126,102,102,102,102,102,102,102
6220 FOR X=1 TO 17 STEP 2:READ Y:H$(X,X)=CHR$(Y):H$(X+1,X+1)=CHR$(Y):NEXT X
6221 DATA 255,241,242,244,8,240,240,240,240
6230 FOR X=1 TO 17 STEP 2:READ Y:Z$(X,X)=CHR$(Y):Z$(X+1,X+1)=CHR$(Y):NEXT X:DATA 255,143,79,47,16,15,15,15,15
6240 GOTO 3000
7000 DATA 2,THE QUALITY OF MERCY IS NOT STRAINED MIM IT DROPPETH AS THE GENTLE RAIN FROM HEAVEN
7001 DATA UPON THE PLACE BENEATH AAA IT IS TWICE BLESSED OS IT BLESSETH HIM THAT GIVES AND HIM THAT TAKES AAA
7010 DATA 2,FRIENDS MIM ROMANS MIM COUNTRYMEN MIM LEND ME YOUR EARS OS I COME TO BURY CAESAR MIM NOT TO
7011 DATA PRAISE HIM AAA THE EVIL THAT MEN DO LIVES AFTER THEM MIM THE GOOD IS OFT INTERRED WITH THEIR BONES AAA
7020 DATA 3,DOUBLE MIM DOUBLE TOIL AND TROUBLE OS FIRE MIM BURN MIM AND CALDRON MIM BUBBLE AAA
7021 DATA FILLET OF A FENNY SNAKE MIM IN THE CALDRON BOIL AND BAKE AAA EYE OF NEWT MIM AND TOE OF FROG MIM
7022 DATA WOOL OF BAT MIM AND TONGUE OF DOG AAA
7030 DATA 3,BUT MIM SOFT MIM WHAT LIGHT THROUGH YONDER WINDOW BREAKS IMI IT IS THE EAST MIM
7031 DATA AND JULIET IS THE SUN AAA ARISE MIM FAIR SUN MIM AND KILL THE ENVIOUS MOON MIM
7032 DATA WHO IS ALREADY SICK AND PALE WITH GRIEF MIM THAT THOU HER MAID ART FAR MORE FAIR THAN SHE AAA
7040 DATA 2,OH MIM THAT THIS TOO TOO SOLID FLESH WOULD MELT MIM THAW MIM AND RESOLVE ITSELF INTO A DEW AAA
7041 DATA OR THAT THE EVERLASTING HAD NOT FIXED HIS CANON GAINST SELF DU SLAUGHTER AAA
7050 DATA 3,TO BE MIM OR NOT TO BE MIM THAT IS THE QUESTION AAA WHETHER TIS NOBLER IN THE MIND TO SUFFER
7051 DATA THE SLINGS AND ARROWS OF OUTRAGEOUS FORTUNE MIM OR TO TAKE ARMS AGAINST A SEA OF TROUBLES MIM
7052 DATA AND BY OPPOSING MIM END THEM AAA
7060 DATA 2,ALAS MIM POOR YORICK AAA I KNEW HIM MIM HORATIO OS A FELLOW OF INFINITE JEST MIM OF MOST
7061 DATA EXCELLENT FANCY AAA HE HATH BORNE ME ON HIS BACK A THOUSAND TIMES AAA
7070 DATA 2,IF WE SHADOWS HAVE OFFENDED MIM THINK BUT THIS MIM AND ALL IS MENDED MIM
7071 DATA THAT YOU HAVE BUT SLUMBERED HERE WHILE THESE VISIONS DID APPEAR AAA
7080 DATA 2,IF YOU PRICK US MIM DO WE NOT BLEED IMI IF YOU TICKLE US MIM DO WE NOT LAUGH IMI
7081 DATA IF YOU POISON US MIM DO WE NOT DIE IMI AND IF YOU WRONG US MIM SHALL WE NOT REVENGE IMI
7090 DATA 5,WE SHALL NOT FLAG OR FAIL AAA WE SHALL GO ON TO THE END AAA WE SHALL FIGHT IN FRANCE MIM WE SHALL
7091 DATA FIGHT ON THE SEAS AND OCEANS MIM WE SHALL FIGHT WITH GROWING CONFIDENCE AND GROWING STRENGTH
7092 DATA IN THE AIR MIM WE SHALL DEFEND OUR ISLAND MIM WHATEVER THE COST MAY BE MIM WE SHALL FIGHT
7093 DATA ON THE BEACHES MIM WE SHALL FIGHT ON THE LANDING GROUNDS MIM WE SHALL FIGHT IN THE FIELDS
7094 DATA AND IN THE STREETS MIM WE SHALL FIGHT IN THE HILLS AAA WE SHALL NEVER SURRENDER AAA

Download

The original program from the Antic disk, to LOAD or ENTER instead of typing it: SEMAFOR.BAS.

Credits