home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
8bitfiles.net/archives
/
archives.tar
/
archives
/
commodore-users-of-norman
/
CUON_36_(10-1984).d64
/
sunny.bas
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2019-04-13
|
6KB
|
310 lines
100 REM PURPOSE --
110 REM
120 REM THIS PROGRAM GIVES THE TIME OF SUNRISE, SUNSET, AND TWILIGHT
130 REM (ASTRONOMICAL,NAUTICAL, AND CIVIL) TO WITHIN A MINUTE OR TWO
140 REM DURING THE SECOND HALF OF THE TWENTIETH CENTURY.
150 REM
160 REM INPUTS --
170 REM
180 REM LATITUDE IN DEGREES, MINUTES, AND SECONDS. NORTH IS POSITIVE.
190 REM EXAMPLE: 30.0028 REPRESENTS 30 DEGREES, 00 MINUTES, 28 SECONDS
200 REM NORTH LATITUDE.
210 REM LONGITUDE IN DEGREES, MINUTES, AND SECONDS. WEST IS POSITIVE.
220 REM EXAMPLE: 90.1109 REPRESENTS 90 DEGREES, 11 MINUTES, 09 SECONDS
230 REM WEST LONGITUDE.
240 REM
250 REM TIME ZONE IN HOURS AND MINUTES THAT ARE ADDED TO WALL CLOCK TIME
260 REM TO YIELD UNIVERSAL TIME.
270 REM IN THE 48 CONTIGUOUS UNITED STATES, SEE TABLE BELOW.
280 REM
290 REM STANDARD DAYLIGHT
300 REM
310 REM EASTERN 5.00 4.00
320 REM CENTRAL 6.00 5.00
330 REM MOUNTAIN 7.00 6.00
340 REM PACIFIC 8.00 7.00
350 REM
360 REM YEAR (1951 THRU 2000)
370 REM
380 REM MONTH (1 THRU 12)
390 REM
400 REM DAY (1 THRU 31)
410 REM
420 REM OUTPUTS --
430 REM
440 REM OUTPUTS ARE GIVEN IN HOURS AND MINUTES ON A 24 HOUR BASIS.
450 REM EXAMPLE: 6.25 REPRESENTS 6:25 A.M., AND 18.25 REPRESENTS 6:25 P.M.
460 REM
470 REM A ZERO OUTPUT INDICATES THAT THE PHENOMENON DOES NOT OCCUR
480 REM ON THE SPECIFIED DATE, E.G., THE SUN DOES NOT SET IN MID-SUMMER
490 REM AT HIGH LATITUDES.
500 REM
510 REM SAMPLE --
520 REM
530 REM LAT
540 REM ? 30
550 REM LON
560 REM ? 90
570 REM ZONE
580 REM ? 5
590 REM YEAR
600 REM ? 1983
610 REM MONTH
620 REM ? 5
630 REM DAY
640 REM ? 19
650 REM
660 REM A DAWN 4.33
670 REM N DAWN 5.06
680 REM C DAWN 5.38
690 REM SUNRIS 6.04
700 REM SUSSET 19.49
710 REM C DUSK 20.15
720 REM N DUSK 20.47
730 REM A DUSK 21.21
740 REM
750 REM -------------------------------
760 REM
770 REM - CONSTANTS
780 REM
790 REM LET
800 A=1.5708
810 B=3.14159265
820 C=4.71239
830 D=6.28319
840 DIM DM(12)
850 REM
860 REM - INPUTS
870 REM
880 PRINTCHR$(147):PRINT" SOME EXAMPLES ARE:":PRINT
890 PRINT" (DEGREES.MINUTESSECONDS[146])":PRINT
900 GOSUB 3060
910 PRINT:INPUT"LATITUDE";Z
920 IFZ>90 ORZ<-90 THEN PRINT"NOT POSSIBLE--TRY AGAIN":FORII=1TO1000:NEXTII:GOTO 880
930 GOSUB 1830
940 E=Z*1.74533E-2
950 REM
960 INPUT"LONGITUDE";Z
970 IF Z>360 OR Z<-360 THEN PRINT"PLEASE TRY AGAIN":GOTO 960
980 GOSUB 1830
990 F=Z*1.74533E-2
1000 REM
1010 PRINT:PRINT:PRINT" (CENTRAL STANDARD=6 -- DAYLIGHT=5)"
1020 INPUT"ZONE";Z
1030 GOSUB 1830
1040 G=Z*2.61799E-1
1050 REM
1060 INPUT"YEAR";H
1070 IF H<100 THEN H=H+1900:PRINT H " ASSUMED"
1080 IF H<2000 AND H>1951 THEN 1100
1090 PRINT"PROG. ONLY WORKS FOR 1951-2000":PRINT"TRY AGAIN":GOTO 1060
1100 REM
1110 INPUT"MONTH";I
1120 IF I<1 OR I>12 THEN PRINT"INVALID RESPONSE--TRY AGAIN":GOTO 1110
1130 REM
1140 INPUT"DAY";J
1150 FOR IJ=1 TO 12:READ DM(IJ):NEXT IJ:RESTORE:IF I=2 THEN GOSUB 3130
1160 IF J<1 OR J>DM(I) THEN PRINT"INVALID RESPONSE--TRY AGAIN":GOTO1140
1170 REM
1180 REM - DAY OF YEAR
1190 REM
1200 K=INT((I+9)/12)
1210 X=H/4
1220 Y=INT(X)
1230 Z=X-Y
1240 IF Z=0 THEN 1260
1250 K=K*2
1260 H=INT(275*I/9)
1270 H=H+J-K-30
1280 REM
1290 REM - RISING PHENOMENA
1300 REM
1310 PRINT" "
1320 REM
1330 I=0
1340 J=A
1350 GOSUB 1960
1360 REM
1370 R=-3.09017E-1
1380 GOSUB 2490
1390 PRINT:PRINT"ANSWER IN (HOURS.MINUTESSECONDS[146])":PRINT
1400 PRINT" ASTRONOMICAL DAWN ";V
1410 REM
1420 R=-2.07912E-1
1430 GOSUB 2490
1440 PRINT" NAUTICAL DAWN ";V
1450 REM
1460 R=-1.04528E-1
1470 GOSUB 2490
1480 PRINT" CIVIL DAWN ";V
1490 REM
1500 R=-1.45439E-2
1510 GOSUB 2490
1520 PRINT" SUNRISE ";V
1530 REM
1540 REM - SETTING PHENOMENA
1550 REM
1560 I=1
1570 J=C
1580 GOSUB 1960
1590 REM
1600 R=-1.45439E-2
1610 GOSUB 2490
1620 PRINT" SUNSET ";V
1630 REM
1640 R=-1.04528E-1
1650 GOSUB 2490
1660 PRINT" CIVIL DUSK ";V
1670 REM
1680 R=-2.07912E-1
1690 GOSUB 2490
1700 PRINT" NAUTICAL DUSK ";V
1710 REM
1720 R=-3.09017E-1
1730 GOSUB 2490
1740 PRINT" ASTRONOMICAL DUSK ";V
1750 REM
1760 PRINT"WANT ANOTHER RUN? (Y/N)"
1770 GET A$: IF A$="" THEN GOTO 1770
1780 IF A$="Y" GOTO 880
1790 GOTO 3050
1800 REM
1810 REM - SEXAGESIMAL TO DECIMAL
1820 REM
1830 W=1
1840 IFZ>=0 THEN 1870
1850 W=-1
1860 Z=ABS(Z)
1870 X=INT(Z)
1880 Z=(Z-X)*100
1890 Y=INT(Z)
1900 Z=(Z-Y)*100
1910 Z=(X+Y/60+Z/3600)*W
1920 RETURN
1930 REM
1940 REM - APPROXIMATE TIME
1950 REM
1960 K=H+((J+F)/D)
1970 REM
1980 REM - SOLAR MEAN ANOMALY
1990 REM
2000 L=K*1.7202E-2
2010 L=L-5.74039E-2
2020 REM
2030 REM - SOLAR TRUE LONGITUDE
2040 REM
2050 Z=SIN(L)
2060 M=L+3.34405E-2*Z
2070 Z=SIN(2*L)
2080 M=M+3.49066E-4*Z
2090 M=M+4.93289
2100 REM
2110 REM - QUADRANT DETERMINATION
2120 REM
2130 Z=M
2140 GOSUB 2980
2150 M=Z
2160 X=M/A
2170 Y=INT(X)
2180 Z=X-Y
2190 IF Z<>0 THEN 2210
2200 M=M+4.84814E-6
2210 N=2
2220 IF M>C THEN 2290
2230 N=1
2240 IF M>A THEN 2290
2250 N=0
2260 REM
2270 REM - SOLAR RIGHT ASCENSION
2280 REM
2290 P=SIN(M)/COS(M)
2300 P=ATN(.91746*P)
2310 REM
2320 REM - QUADRANT ADJUSTMENT
2330 REM
2340 IF N=0 THEN 2420
2350 IF N=2 THEN 2380
2360 P=P+B
2370 GOTO 2420
2380 P=P+D
2390 REM
2400 REM - SOLAR DECLINATION
2410 REM
2420 Q=.39782*SIN(M)
2430 Q=Q/SQR(-Q*Q+1)
2440 LETQ=ATN(Q)
2450 RETURN
2460 REM
2470 REM - COORDINATE CONVERSION
2480 REM
2490 S=R-(SIN(Q)*SIN(E))
2500 S=S/(COS(Q)*COS(E))
2510 REM
2520 REM - NULL PHENOMENON
2530 REM
2540 Z=ABS(S)
2550 IF Z<=1 THEN 2610
2560 V=0
2570 RETURN
2580 REM
2590 REM - ADJUSTMENT
2600 REM
2610 S=S/SQR(-S*S+1)
2620 S=-ATN(S)+A
2630 IF I=1 THEN 2680
2640 S=D-S
2650 REM
2660 REM - LOCAL APPARENT TIME
2670 REM
2680 Z=1.72028E-2*K
2690 T=S+P-Z-1.73364
2700 REM
2710 REM - UNIVERSAL TIME
2720 REM
2730 U=T+F
2740 REM
2750 REM - WALL CLOCK TIME
2760 REM
2770 V=U-G
2780 REM
2790 REM - DECIMAL TO SEXAGESIMAL
2800 REM
2810 Z=V
2820 GOSUB 2980
2830 Z=Z*3.81972
2840 V=INT(Z)
2850 W=(Z-V)*60
2860 X=INT(W)
2870 Y=W-X
2880 IF Y<.5 THEN 2900
2890 X=X+1
2900 IF X<60 THEN 2930
2910 V=V+1
2920 X=0
2930 V=V+X/100
2940 RETURN
2950 REM
2960 REM - NORMALIZATION
2970 REM
2980 IF Z>=0 THEN 3010
2990 Z=Z+D
3000 GOTO 2980
3010 IF Z<D THEN 3040
3020 Z=Z-D
3030 GOTO 3010
3040 RETURN
3050 END
3060 PRINT" CITY LAT. LONG."
3070 PRINT"MY HOUSE 34.4118 96.4144"
3080 PRINT"ADA 34.4422 96.4144"
3090 PRINT"PURCELL 35.0104 97.2128"
3100 PRINT"ACREAGE 34.5715 97.3000"
3110 PRINT"NORMAN 35.1138 97.2636"
3120 RETURN
3130 X=H/4:Y=INT(X):Z=X-Y:IF Z=0 THEN DM(2)=29
3140 RETURN
3150 DATA31,28,31,30,31,30,31,31,30,31,30,31
3160 REM
3170 REM FROM THE LIBRARY OF
3180 REM BILL BUCHANAN