ChipMaster's bwBASIC This also includes history going back to v2.10. *WARN* some binary files might have been corrupted by CRLF.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

141 lines
3.8 KiB

  1. 10 ' Sunrise-Sunset
  2. 20 GOSUB 300
  3. 30 INPUT "Lat, Long (deg)";B5,L5
  4. 40 INPUT "Time zone (hrs)";H
  5. 50 L5=L5/360: Z0=H/24
  6. 60 GOSUB 1170: T=(J-2451545)+F
  7. 70 TT=T/36525+1: ' TT = centuries
  8. 80 ' from 1900.0
  9. 90 GOSUB 410: T=T+Z0
  10. 100 '
  11. 110 ' Get Sun's Position
  12. 120 GOSUB 910: A(1)=A5: D(1)=D5
  13. 130 T=T+1
  14. 140 GOSUB 910: A(2)=A5: D(2)=D5
  15. 150 IF A(2)<A(1) THEN A(2)=A(2)+P2
  16. 160 Z1=DR*90.833: ' Zenith dist.
  17. 170 S=SIN(B5*DR): C=COS(B5*DR)
  18. 180 Z=COS(Z1): M8=0: W8=0: PRINT
  19. 190 A0=A(1): D0=D(1)
  20. 200 DA=A(2)-A(1): DD=D(2)-D(1)
  21. 210 FOR C0=0 TO 23
  22. 220 P=(C0+1)/24
  23. 230 A2=A(1)+P*DA: D2=D(1)+P*DD
  24. 240 GOSUB 490
  25. 250 A0=A2: D0=D2: V0=V2
  26. 260 NEXT
  27. 270 GOSUB 820: ' Special msg?
  28. 280 END
  29. 290 '
  30. 300 ' Constants
  31. 310 DIM A(2),D(2)
  32. 320 P1=3.14159265: P2=2*P1
  33. 330 DR=P1/180: K1=15*DR*1.0027379
  34. 340 S$="Sunset at "
  35. 350 R$="Sunrise at "
  36. 360 M1$="No sunrise this date"
  37. 370 M2$="No sunset this date"
  38. 380 M3$="Sun down all day"
  39. 390 M4$="Sun up all day"
  40. 400 RETURN
  41. 410 ' LST at 0h zone time
  42. 420 T0=T/36525
  43. 430 S=24110.5+8640184.813*T0
  44. 440 S=S+86636.6*Z0+86400*L5
  45. 450 S=S/86400: S=S-INT(S)
  46. 460 T0=S*360*DR
  47. 470 RETURN
  48. 480 '
  49. 490 ' Test an hour for an event
  50. 500 L0=T0+C0*K1: L2=L0+K1
  51. 510 H0=L0-A0: H2=L2-A2
  52. 520 H1=(H2+H0)/2: ' Hour angle,
  53. 530 D1=(D2+D0)/2: ' declination,
  54. 540 ' at half hour
  55. 550 IF C0>0 THEN 570
  56. 560 V0=S*SIN(D0)+C*COS(D0)*COS(H0)-Z
  57. 570 V2=S*SIN(D2)+C*COS(D2)*COS(H2)-Z
  58. 580 IF SGN(V0)=SGN(V2) THEN 800
  59. 590 V1=S*SIN(D1)+C*COS(D1)*COS(H1)-Z
  60. 600 A=2*V2-4*V1+2*V0: B=4*V1-3*V0-V2
  61. 610 D=B*B-4*A*V0: IF D<0 THEN 800
  62. 620 D=SQR(D)
  63. 630 IF V0<0 AND V2>0 THEN PRINT R$;
  64. 640 IF V0<0 AND V2>0 THEN M8=1
  65. 650 IF V0>0 AND V2<0 THEN PRINT S$;
  66. 660 IF V0>0 AND V2<0 THEN W8=1
  67. 670 E=(-B+D)/(2*A)
  68. 680 IF E>1 OR E<0 THEN E=(-B-D)/(2*A)
  69. 690 T3=C0+E+1/120: ' Round off
  70. 700 H3=INT(T3): M3=INT((T3-H3)*60)
  71. 710 PRINT USING "##:##";H3;M3;
  72. 720 H7=H0+E*(H2-H0)
  73. 730 N7=-COS(D1)*SIN(H7)
  74. 740 D7=C*SIN(D1)-S*COS(D1)*COS(H7)
  75. 750 AZ=ATN(N7/D7)/DR
  76. 760 IF D7<0 THEN AZ=AZ+180
  77. 770 IF AZ<0 THEN AZ=AZ+360
  78. 780 IF AZ>360 THEN AZ=AZ-360
  79. 790 PRINT USING ", azimuth ###.#";AZ
  80. 800 RETURN
  81. 810 '
  82. 820 ' Special-message routine
  83. 830 IF M8=0 AND W8=0 THEN 870
  84. 840 IF M8=0 THEN PRINT M1$
  85. 850 IF W8=0 THEN PRINT M2$
  86. 860 GOTO 890
  87. 870 IF V2<0 THEN PRINT M3$
  88. 880 IF V2>0 THEN PRINT M4$
  89. 890 RETURN
  90. 900 '
  91. 910 ' Fundamental arguments
  92. 920 ' (Van Flandern &
  93. 930 ' Pulkkinen, 1979)
  94. 940 L=.779072+.00273790931*T
  95. 950 G=.993126+.0027377785*T
  96. 960 L=L-INT(L): G=G-INT(G)
  97. 970 L=L*P2: G=G*P2
  98. 980 V=.39785*SIN(L)
  99. 990 V=V-.01000*SIN(L-G)
  100. 1000 V=V+.00333*SIN(L+G)
  101. 1010 V=V-.00021*TT*SIN(L)
  102. 1020 U=1-.03349*COS(G)
  103. 1030 U=U-.00014*COS(2*L)
  104. 1040 U=U+.00008*COS(L)
  105. 1050 W=-.00010-.04129*SIN(2*L)
  106. 1060 W=W+.03211*SIN(G)
  107. 1070 W=W+.00104*SIN(2*L-G)
  108. 1080 W=W-.00035*SIN(2*L+G)
  109. 1090 W=W-.00008*TT*SIN(G)
  110. 1100 '
  111. 1110 ' Compute Sun's RA and Dec
  112. 1120 S=W/SQR(U-V*V)
  113. 1130 A5=L+ATN(S/SQR(1-S*S))
  114. 1140 S=V/SQR(U):D5=ATN(S/SQR(1-S*S))
  115. 1150 R5=1.00021*SQR(U)
  116. 1160 RETURN
  117. 1165 '
  118. 1170 ' Calendar --> JD
  119. 1180 INPUT "Year, Month, Day";Y,M,D
  120. 1190 G=1: IF Y<1583 THEN G=0
  121. 1200 D1=INT(D): F=D-D1-.5
  122. 1210 J=-INT(7*(INT((M+9)/12)+Y)/4)
  123. 1220 IF G=0 THEN 1260
  124. 1230 S=SGN(M-9): A=ABS(M-9)
  125. 1240 J3=INT(Y+S*INT(A/7))
  126. 1250 J3=-INT((INT(J3/100)+1)*3/4)
  127. 1260 J=J+INT(275*M/9)+D1+G*J3
  128. 1270 J=J+1721027+2*G+367*Y
  129. 1280 IF F>=0 THEN 1300
  130. 1290 F=F+1: J=J-1
  131. 1300 RETURN
  132. 1310 '
  133. 1320 ' This program by Roger W. Sinnott calculates the times of sunrise
  134. 1330 ' and sunset on any date, accurate to the minute within several
  135. 1340 ' centuries of the present. It correctly describes what happens in the
  136. 1350 ' arctic and antarctic regions, where the Sun may not rise or set on
  137. 1360 ' a given date. Enter north latitudes positive, west longitudes
  138. 1370 ' negative. For the time zone, enter the number of hours west of
  139. 1380 ' Greenwich (e.g., 5 for EST, 4 for EDT). The calculation is
  140. 1390 ' discussed in Sky & Telescope for August 1994, page 84.