REM --- GC/CON1C.BAS --- Great Circle Program setup for \
	Direct Console Input, Version 1.0 in CBasic.
REM --- GC/INIT.BAS --- CONSTANTS AND FUNCTION DEFINES -----
V$="######.#": V1$="###.#"
D=1: M=57.29577951308254: N=1.570796326794896
DEF FNDMS(D,M,S)= D+(M/60)+(S/3600)
DEF FNCR$(YPOS,XPOS)=CHR$(27)+"="+CHR$(YPOS+32)+CHR$(XPOS+32)
DEF FNARC(X)= N-2*ATN(X/(1+SQR(1-X*X)))
REM -----ENTRY1.BAS ---- GREAT CIRCLE DIRECT ENTRY ROUTINE -----\
     ----- Osborne 1 Cursor Positioning Input Routine ------
100	PRINT CHR$(26) \<----- clear screen
    REM  --- Screen #1 Home location entry ----
	D=1: MIN1=0: SEC1=0: MIN3=0: SEC3=0
	PRINT CHR$(26)
	PRINT FNCR$(5,8);"GREAT CIRCLE DISTANCE and HEADING"
	PRINT FNCR$(8,8);"Enter the home location:"
	PRINT FNCR$(11,10);"Latitude  (N or S) ?  Degrees ?"
	PRINT FNCR$(12,32);"Minutes ?"
	PRINT FNCR$(13,32);"Seconds ?"
	PRINT FNCR$(15,10);"Longitude (E or W) ?  Degrees ?"
	PRINT FNCR$(16,32);"Minutes ?"
	PRINT FNCR$(17,32);"Seconds ?"
	PRINT FNCR$(11,28);
	  INPUT"";H1$
	PRINT FNCR$(11,40);
	  INPUT"";DEG1
	PRINT FNCR$(12,40);
	  INPUT"";MIN1
	PRINT FNCR$(13,40);
	  INPUT"";SEC1
	PRINT FNCR$(15,28);
	  INPUT"";H3$
	PRINT FNCR$(15,40);
	  INPUT"";DEG3
	PRINT FNCR$(16,40);
	  INPUT"";MIN3
	PRINT FNCR$(17,40);
	  INPUT"";SEC3
 REM --- ENTRY2.BAS --- GREAT CIRCLE DIRECT ENTRY OF TARGET LOCATION ---
300	PRINT CHR$(26)
     REM  --- Screen #2 Target location entry -----
	MIN2=0: SEC2=0: MIN4=0: SEC4=0
	PRINT FNCR$(5,8);"GREAT CIRCLE DISTANCE and HEADING"
	PRINT FNCR$(8,8);"Enter the target location:"
	PRINT FNCR$(11,10);"Latitude  (N or S) ?  Degrees ?"
	PRINT FNCR$(12,32);"Minutes ?"
	PRINT FNCR$(13,32);"Seconds ?"
	PRINT FNCR$(15,10);"Longitude (E or W) ?  Degrees ?"
	PRINT FNCR$(16,32);"Minutes ?"
	PRINT FNCR$(17,32);"Seconds ?"
	PRINT FNCR$(11,28);
	  INPUT"";H2$
	PRINT FNCR$(11,40);
	  INPUT"";DEG2
	PRINT FNCR$(12,40);
	  INPUT"";MIN2
	PRINT FNCR$(13,40);
	  INPUT"";SEC2
	PRINT FNCR$(15,28);
	  INPUT"";H4$
	PRINT FNCR$(15,40);
	  INPUT"";DEG4
	PRINT FNCR$(16,40);
	  INPUT"";MIN4
	PRINT FNCR$(17,40);
	  INPUT"";SEC4
     REM ------- DMS TO Decimal Conversion -------
	LAT1= FNDMS(DEG1,MIN1,SEC1)
	LAT2= FNDMS(DEG2,MIN2,SEC2)
	LON1= FNDMS(DEG3,MIN3,SEC3)
	LON2= FNDMS(DEG4,MIN4,SEC4)
     REM ----- Upper/Lower Conversion -----
	   IF H1$= "s" THEN H1$= "S"
	   IF H2$= "s" THEN H2$= "S"
	   IF H3$= "w" THEN H3$= "W"
   	   IF H4$= "w" THEN H4$= "W"
     REM  ---- E & S Conversion ----
	   IF H1$= "S" AND D=1 THEN LAT1= LAT1*(-1)
	   IF H2$= "S" THEN LAT2= LAT2*(-1)
	   IF H3$= "W" AND D=1 THEN LON1= LON1*(-1)
   	   IF H4$= "W" THEN LON2= LON2*(-1)
REM --- SCRN/OUT.BAS ----\
      --- Screen #3 Stand-by while calculating ----
	PRINT CHR$(26)   rem <----- Clear Screen
	PRINT FNCR$(4,10); "GREAT CIRCLE DISTANCE and HEADING "
	PRINT FNCR$(6,10);"Now calculating the values for :"
	PRINT FNCR$(8,6) ;"Home  location  at ";
	   PRINT USING V1$;ABS(LAT1);
		PRINT " degrees ";H1$;" latitude"
	PRINT FNCR$(9,25);
	   PRINT USING V1$;ABS(LON1);
		PRINT " degrees ";H3$;" longitude    "
	PRINT FNCR$(11,24);"To"
	PRINT FNCR$(13,6);"Target location at ";
	   PRINT USING V1$;ABS(LAT2);
		PRINT " degrees ";H2$;" latitude"
	PRINT FNCR$(14,25);
	   PRINT USING V1$;ABS(LON2);
		PRINT" degrees ";H4$;" longitude    "
GOSUB 68: rem ---- GC/NUCAL MODULE  \
       ---- Calling and Output Module ----
	PRINT FNCR$(6,10) ;"    These are the values for      " 
	PRINT FNCR$(16,10);"The distance is:";
	   PRINT USING V$;NAMI;
		PRINT " Nautical miles"
	PRINT FNCR$(17,26);
	   PRINT USING V$;STMI;
		PRINT " Statute miles"
	PRINT FNCR$(18,26);
	   PRINT USING V$;KM;
		PRINT " Kilometers"
	PRINT FNCR$(20,10);"At a bearing of ";
	   PRINT USING V1$;BA;
		PRINT " degrees"
	PRINT FNCR$(21,10);"And a reverse bearing of ";
	   PRINT USING V1$;BR;
		PRINT " degrees"
REM  ----------- Repeat Option ----------
	CONSOLE
	PRINT FNCR$(22,1);"Try again ?"
	PRINT FNCR$(22,11);
990	ANS%= CONCHAR%
	IF CHR$(ANS%) = "N" OR CHR$(ANS%) = "n"  THEN 999
	IF CHR$(ANS%) <> "Y" AND CHR$(ANS%) <> "y" THEN 990
      REM  ---- Screen #4 Repeat Menu ----
	PRINT CHR$(26)
	PRINT FNCR$(5,10);"GREAT CIRCLE DISTANCE and HEADING"
	PRINT FNCR$(9,10);"You now have a choice:"
	PRINT FNCR$(11,12);"A - Keep the SAME home location"
	PRINT FNCR$(13,12);"B - Choose a NEW home location"
	PRINT FNCR$(15,12);"C - QUIT"
	PRINT FNCR$(17,10);"Which will it be, A, B, or C ?"
	PRINT FNCR$(17,36);
	ANS%= CONCHAR%
	IF CHR$(ANS%) = "A" THEN 300
	IF CHR$(ANS%) = "B" THEN 100
	IF CHR$(ANS%) = "C" THEN 999
999	PRINT CHR$(26): PRINT: PRINT: PRINT
	PRINT "            THAT'S ALL !!!"
	GOTO 99.9

REM --- Great Circle Calculate Module derived from a      \
	FORTRAN program. From "The Giant Book of Computer \
	Software", pages 199-207. Modified and Corrected  \
	by O. Bliss. NOTE that SOUTH Latitutes and WEST   \
	Longitutes are entered as negative numbers.\

68	A1= LAT1/M:  A2= LAT2/M:  L1= LON1/M:  L2= LON2/M
	PI= 3.141592653589794: FLAG=0
68.1	Q1= COS(A1) * ((TAN(A1) * COS(L2-L1)) - TAN(A2))/SIN(L2-L1)
	X1= 270 + (M * ATN(Q1))
  	IF (L2-L1) > 0 AND (L2-L1) <= PI  OR \
	(L2-L1) < 0 AND ABS(L2-L1) >= PI THEN X1= X1- 180 
   REM -- Reverse Calculation --
	IF FLAG= 2 THEN 68.2
	L3=L2: L4=L1: L2=L4: L1=L3
	A3=A2: A4=A1: A2=A4: A1=A3
	Y1=X1: FLAG=2: GOTO 68.1
68.2	C1= ABS(L2-L1)
	IF C1> PI THEN C1= 2.0 * PI - C1
   REM -- ARC COSINE Conversion ---
	Z= FNARC(SIN(A1)*SIN(A2)+COS(A1)*COS(A2)*COS(C1))
	Z1= Z * M
   REM -- Module Output --
	BA= Y1 + .05
	BR= X1 + .05
	INTM= 60 * Z1
	NAMI= INTM + .05
	KM= INTM * 1.8519 + .05
	STMI= INTM * 1.1507765 + .05
RETURN
99.9	END