10 '   GREAT CIRCLE DISTANCE AND HEADING
20 '   by Orbra Bliss, version 1.0  1/4/84
30 DEFDBL A,B,C,D,E,L,M: DEFSTR V: V="######.#": V1="###.##"
40 D=1: K=111.11: M=57.29577951308243#: N=60: S=69.041
50 DEF FNDMS(D,M,S)= D+(M/60)+(S/3600)
60 DEF FNCR$(YPOS,XPOS)=CHR$(27)+"="+CHR$(YPOS+32)+CHR$(XPOS+32)
70 '-- Osborne 1 Cursor Positioning Input Routine ------
80 :
90 '--- Screen #1 Home location entry ----
100 PRINT CHR$(26):D=1:MIN1=0:SEC1=0:MIN3=0:SEC3=0
110 PRINT FNCR$(5,8);"GREAT CIRCLE DISTANCE and HEADING"
120 PRINT FNCR$(8,8);"Enter the home location:"
130 PRINT FNCR$(11,10);"Latitude  (N or S)  ? Degrees ?"
140 PRINT FNCR$(12,32);"Minutes ?"
150 PRINT FNCR$(13,32);"Seconds ?"
160 PRINT FNCR$(15,10);"Longitude (E or W)  ? Degrees ?"
170 PRINT FNCR$(16,32);"Minutes ?"
180 PRINT FNCR$(17,32);"Seconds ?"
190 PRINT FNCR$(11,30);: INPUT"",H1$
200 PRINT FNCR$(11,40);: INPUT"",DEG1
210 PRINT FNCR$(12,40);: INPUT"",MIN1
220 PRINT FNCR$(13,40);: INPUT"",SEC1
230 PRINT FNCR$(15,30);: INPUT"",H3$
240 PRINT FNCR$(15,40);: INPUT"",DEG3
250 PRINT FNCR$(16,40);: INPUT"",MIN3
260 PRINT FNCR$(17,40);: INPUT"",SEC3
270 PRINT CHR$(26) ' <---- clear screen
280 :
290 ' --- Screen #2 Target location entry -----
300 PRINT CHR$(26):MIN2=0:SEC2=0:MIN4=0:SEC4=0
310 PRINT FNCR$(5,8);"GREAT CIRCLE DISTANCE and HEADING"
320 PRINT FNCR$(8,8);"Enter the target location:"
330 PRINT FNCR$(11,10);"Latitude  (N or S)  ? Degrees ?"
340 PRINT FNCR$(12,32);"Minutes ?"
350 PRINT FNCR$(13,32);"Seconds ?"
360 PRINT FNCR$(15,10);"Longitude (E or W)  ? Degrees ?"
370 PRINT FNCR$(16,32);"Minutes ?"
380 PRINT FNCR$(17,32);"Seconds ?"
390 PRINT FNCR$(11,30);: INPUT"",H2$
400 PRINT FNCR$(11,40);: INPUT"",DEG2
410 PRINT FNCR$(12,40);: INPUT"",MIN2
420 PRINT FNCR$(13,40);: INPUT"",SEC2
430 PRINT FNCR$(15,30);: INPUT"",H4$
440 PRINT FNCR$(15,40);: INPUT"",DEG4
450 PRINT FNCR$(16,40);: INPUT"",MIN4
460 PRINT FNCR$(17,40);: INPUT"",SEC4
470 PRINT CHR$(26) ' <---- clear screen
480 :
490  '------- DMS TO Decimal Conversion -------
500 LAT1= FNDMS(DEG1,MIN1,SEC1)
510 LAT2= FNDMS(DEG2,MIN2,SEC2)
520 LON1= FNDMS(DEG3,MIN3,SEC3)
530 LON2= FNDMS(DEG4,MIN4,SEC4)
540 :
550 ' ---- E & S Conversion ----
560 IF H1$= "S" AND D=1 THEN LAT1= LAT1*-1
570 IF H2$= "S" THEN LAT2= LAT2*-1
580 IF H3$="E" AND D=1 THEN LON1= LON1*-1
590 IF H4$="E" THEN LON2= LON2*-1
600 A=LAT1/M: B=LAT2/M
610 :
620 ' --- Screen #3 Stand-by while calculating ----
630 PRINT FNCR$(4,10);"GREAT CIRCLE DISTANCE and HEADING"
640 PRINT FNCR$(6,10);"Now calculating the values for :"
650 PRINT FNCR$(8,6) ;"Home  location  at ";:PRINT USING V1;ABS(LAT1);:PRINT " degrees ";H1$;" latitude"
660 PRINT FNCR$(9,25) USING V1;ABS(LON1);:PRINT " degrees ";H3$;" longitude    "
670 PRINT FNCR$(11,24);"To"
680 PRINT FNCR$(13,6);"Target location at ";:PRINT USING V1;ABS(LAT2);:PRINT " degrees ";H2$;" latitude"
690 PRINT FNCR$(14,25) USING V1;ABS(LON2);:PRINT" degrees ";H4$;" longitude    "
700 :
710 ' ---- Calling and Output Module ----
720 GOSUB 1010
730 PRINT FNCR$(6,10) ;"    These are the values for      " 
740 PRINT FNCR$(16,10);"The distance is:";:PRINT USING V;NAMI;:PRINT " Nautical miles"
750 PRINT FNCR$(17,26) USING V;STMI;:PRINT " Statute miles"
760 PRINT FNCR$(18,26) USING V;KM;:PRINT " Kilometers"
770 PRINT FNCR$(20,10);"At a bearing of ";:PRINT USING V1;B;:PRINT " degrees"
780 :
790 ' ----------- Repeat Option ----------
800 PRINT FNCR$(22,1);"Try again ?"
810 PRINT FNCR$(22,11);: A$=INKEY$
820 IF A$= "N" THEN 980
830 IF A$<> "Y" THEN 810
840 :
850 ' ---- Screen #4 Repeat Menu ----
860 PRINT CHR$(26)
870 PRINT FNCR$(5,10);"GREAT CIRCLE DISTANCE and HEADING"
880 PRINT FNCR$(9,10);"You now have a choice:"
890 PRINT FNCR$(11,12);"A - Keep the SAME home location"
900 PRINT FNCR$(13,12);"B - Choose a NEW home location"
910 PRINT FNCR$(15,12);"C - QUIT"
920 PRINT FNCR$(17,10);"Which will it be, A, B, or C ?"
930 PRINT FNCR$(17,36);:A$=INKEY$
940 IF A$= "A" THEN 300
950 IF A$= "B" THEN 100
960 IF A$= "C" THEN 980
970 GOTO 930
980 PRINT CHR$(26)
990 END
1000 ' ------ Distance & Heading SBR ----------
1010 L=(LON1-LON2)/M
1020 E=SIN(A)*SIN(B)+COS(A)*COS(B)*COS(L)
1030 D=-ATN(E/SQR(1-E*E))+1.57079
1040 C=(SIN(B)-SIN(A)*E)/(COS(A)*SIN(D))
1050 :
1060 C=-ATN(C/SQR(1-C*C))+1.57079
1070 C=C*M
1080 IF SIN(L)<0 THEN C= 360-C
1090 :
1100 ' ---- Round off to one decimal ---
1110 I=D*S*M: GOSUB 1210
1120 STMI=I
1130 I=D*K*M: GOSUB 1210
1140 KM=I
1150 I=D*N*M: GOSUB 1210
1160 NAMI=I
1170 I=C: GOSUB 1210
1180 B=I
1190 :
1200 ' ---- Rounding to two places ----
1210 I=INT((I*100)+.5)/100
1220 RETURN
