Compucolor.org – Virtual Media

Listing of file='RELA.BAS;01' on disk='vmedia/mixed-sector.ccvf'

100 REM  "RELA.BAS"; A RELATIVISTIC SPACE FLIGHT
110 REM  COPYRIGHT (C) 1986 BY WALLACE R. RUST
120 REM  523 BRITTON ROAD, GREECE, NY 14616
130 REM  VERSION 11/86
140 REM  SEE "RELAI.BAS" FOR INSTRUCTIONS
150 REM
200 REM  --- TITLE PAGE
210 PLOT 6,3,12
220 PRINT TAB( 16);:PLOT 14,6,11
225 PRINT " A RELATIVISTIC SPACE FLIGHT "
230 PRINT :PLOT 6,6
240 PRINT TAB( 20);"BY WALLACE R. RUST"
250 PRINT :PRINT :PLOT 6,1
260 INPUT "DO YOU WANT INSTRUCTIONS? ";Q$
270 IF LEFT$ (Q$,1)= "N"THEN 1000
300 REM  --- INSTRUCTIONS
310 LOAD "RELAI":RUN
330 REM  --- LIST OF CONSTANTS, ARRAYS, VARIABLES, FUNCTIONS
340 REM
350 REM  C1 VELOCITY OF LIGHT IN M/S
355 REM  C2 VELOCITY OF LIGHT SQUARED
360 REM  SY SECONDS/YEAR
365 REM  MY METRES/LIGHT-YEAR
370 REM  KY KILOMETRES/LIGHT-YEAR
375 REM  GE EARTH GRAVITY IN M/S/S
380 REM
385 REM  A(J) CONDITIONS AT START OF TRIP
390 REM  B(J) CONDITIONS AT START OF CURRENT ACCELERATION VALUE
395 REM  C(J) CURRENT CONDITIONS
400 REM
405 REM   WHERE:
410 REM
415 REM  J=0: CLOCK TIME ON ROCKET (SEC)
420 REM    1: CLOCK TIME ON ROCKET (YEARS)
425 REM    2: CLOCK TIME ON EARTH (SEC)
430 REM    3: CLODK TIME ON EARTH (YEARS)
435 REM    4: ASTRONAUT AGE (YEARS)
440 REM    5: EARTH-TWIN AGE (YEARS)
445 REM    6: ROCKET VELOCITY (M/S)
450 REM    7: ROCKET VELOCITY (BETA, OR V/C)
455 REM    8: ROCKET DISTANCE FROM EARTH (KM)
460 REM    9: ROCKET DISTANCE FROM EARTH (LIGHT-YEARS)
465 REM   10: ROCKET VELOCITY PARAMETER THETA
470 REM
500 REM  AG ACCEL. OF ROCKET (M/S/S)
505 REM  AR ACCEL. OF ROCKET (EARTH G'S)
510 REM  DF TRIP DIRECTION FLAG (-1 OR +1)
515 REM  DN DECEL. NEEDED TO REACH DESTINATION (M/S/S)
520 REM  ES ELAPSED SECONDS (ROCKET)
525 REM  EY ELAPSED YEARS (ROCKET)
530 REM  GS G-STAR (=AR/C2)
535 REM  NL DISTANCE EARTH TO NEMO (LIGHT-YEARS)
540 REM  NM DISTANCE EARTH TO NEMO (METRES)
545 REM  RP ROCKET PLOT POSITION ON SCREEN (3 TO 61)
550 REM  TA TAU (TIME IN LIGHT-METRES)
555 REM  TH VELOCITY PARAMETER THETA (DIMENSIONLESS)
560 REM  TS TIME INCREMENT ON ROCKET (SEC)
565 REM  TY TIME INCREMENT ON ROCKET (YEARS)
570 REM  X1 DISTANCE INCREMENT (METRES)
575 REM  X2 TIME INCREMENT (SEC)
580 REM  X3 DISTANCE TO GO (METRES)
590 REM
600 REM  FN B1(X) = SINH(X)
610 REM  FN B2(X) = COSH(X)
620 REM  FN B3(X) = TANH(X)
630 REM
1000 REM  --- HOUSEKEEPING
1010 CLEAR 200
1020 REM  RESERVE VARIABLE SPACE
1030 J= 0:X= 0:Y= 0:Z= 0:X1= 0:X2= 0:X3= 0:X4= 0:NL= 0:NM= 0
1040 TA= 0:TH= 0:TS= 0:ES= 0:TY= 0:EY= 0:AR= 0:AG= 0:DF= 0:RP= 0
1050 DN= 0:GS= 0:A$= " ":Q$= " "
1090 S$= "               ":REM  15
1100 C1= 2.9979246E8:C2= 8.9875518E16
1110 SY= 3.15567E7
1120 MY= 9.461452E15
1130 KY= 9.461452E12
1140 GE= 9.8
1400 DEF FN B1(X)= (EXP (X)- EXP (- X))/ 2:REM   SINH(X)
1410 DEF FN B2(X)= (EXP (X)+ EXP (- X))/ 2:REM   COSH(X)
1420 DEF FN B3(X)= FN B1(X)/ FN B2(X):REM        TANH(X)
1510 DIM A(10),B(10),C(10)
1550 REM
2000 REM  --- INPUT DISTANCE TO NEMO
2010 PLOT 6,2,14,12
2020 PRINT "YOU WILL BE TRAVELING BY ROCKET FROM EARTH TO NEMO."
2030 PRINT
2040 INPUT "HOW FAR AWAY IS NEMO, IN LIGHT-YEARS? (1 TO 50) ";NL
2100 IF NL< 1OR NL> 50THEN 2040
2110 NM= NL* MY
2300 REM  --- INITIALIZE VALUES
2310 FOR J= 0TO 10:A(J)= 0:NEXT J
2320 A(4)= 21:A(5)= 21
2330 FOR J= 0TO 10:C(J)= A(J):NEXT J
2350 AR= 0:AG= 0:DF= 1:DN= 0
2700 REM  --- DRAW DISPLAY
2705 PLOT 6,3,15,27,24,12
2710 REM  FLIGHT PATH
2715 PLOT 6,38:PRINT " FLIGHT PATH "
2720 PLOT 6,2:PRINT "tu";TAB( 62);:PLOT 6,6:PRINT "tu"
2725 PLOT 3,0,2
2730 PLOT 6,2:PRINT "vw";TAB( 62);:PLOT 6,6:PRINT "vw"
2740 PLOT 6,1:PRINT "EARTH";
2750 PLOT 6,4:PRINT TAB( 12);"<---- TOTAL DISTANCE";NL;" LIGHT-YEARS ---->";
2760 PLOT 6,1:PRINT TAB( 60);"NEMO"
2800 REM  STATUS BOARD
2805 PLOT 6,38,3,0,6:PRINT " STATUS BOARD "
2810 PLOT 6,2
2820 PRINT "  GREEN  = EARTH REFERENCE"
2825 PLOT 6,3
2830 PRINT "  YELLOW = ROCKET REFERENCE"
2840 PLOT 6,3:PRINT
2850 PRINT "ROCKET ACCELERATION (M/S/S) ........"
2860 PRINT "ROCKET ACCELERATION (G'S) .........."
2880 PRINT "ROCKET CLOCK TIME (S) .............."
2890 PRINT "ROCKET CLOCK TIME (YEARS) .........."
2900 PLOT 6,2
2910 PRINT "EARTH CLOCK TIME (S) ..............."
2920 PRINT "EARTH CLOCK TIME (YEARS) ..........."
2930 PLOT 6,3
2940 PRINT "ASTRONAUT AGE (YEARS) .............."
2950 PLOT 6,2
2960 PRINT "EARTH-TWIN AGE (YEARS) ............."
2980 PRINT "ROCKET VELOCITY (M/S) .............."
2990 PRINT "ROCKET VELOCITY (V/C) .............."
3000 PRINT "ROCKET DIST FROM EARTH (KM) ........"
3010 PRINT "ROCKET DIST FROM EARTH (LT-YRS) ...."
3020 PRINT
3025 PLOT 6,3
3030 PRINT "REQ'D DECEL TO REACH DESTINATION ..."
4000 REM  MESSAGE AREA
4010 PLOT 6,38,3,0,26:PRINT " MESSAGE AREA "
4100 REM  --- ROCKET LAUNCH
4110 GOSUB 20000:GOSUB 22000
4120 PLOT 6,1,3,0,31,11
4130 INPUT "PRESS <RETURN> WHEN READY TO BEGIN YOUR JOURNEY!";Q$
4140 GOSUB 22000
4150 PRINT "FOR LAUNCH, ACCELERATION MUST EXCEDE EARTH'S GRAVITY, WHICH"
4160 PRINT "IS 9.8 M/S/S."
4170 PLOT 3,0,30,6,1,11
4180 PRINT "ENTER LIFTOFF ACCELERATION (15 TO 100), OR"
4185 INPUT "ENTER ZERO TO BYPASS LAUNCH PHASE: ";X
4186 IF X= 0THEN 4400
4190 IF X< 15OR X> 100THEN 4170
4200 AR= X:AG= AR/ GE
4210 GOSUB 22000
4220 PRINT "WE HAVE LIFTOFF!  WAIT FOR VELOCITY = 7400 M/S"
4230 TS= 2:REM  2-SEC STEPS
4235 ES= 0:P= AR- GE
4240 ES= ES+ TS
4250 C(0)= ES
4251 C(2)= ES
4252 C(6)= P* ES
4253 C(7)= C(6)/ C1
4254 C(8)= C(6)/ 38:REM  APPROX ONLY!
4260 GOSUB 20000
4280 IF C(6)> = 7400THEN 4400
4290 GOTO 4240
4400 REM  --- IN EARTH ORBIT
4410 AR= 0:AG= 0
4430 GOSUB 20000:GOSUB 22000
4500 PRINT "YOU ARE NOW IN EARTH ORBIT, AND ENGINE IS SHUT DOWN."
4520 PLOT 6,1,3,0,31,11
4530 INPUT "ENTER ACCELERATION TO LEAVE ORBIT (2 TO 30): ";X
4540 IF X< 2OR X> 30THEN 4520
4550 AR= X:AG= AR/ GE:GS= AR/ C2
4560 GOSUB 28000
4620 REM  --- LEAVE EARTH ORBIT
4640 GOSUB 22000
4650 PRINT "YOU ARE ON THE WAY TO NEMO.  TO CHANGE THE ACCELERATION AT ANY"
4660 PRINT "TIME, PRESS <HOME> KEY."
4670 TS= SY/ 20:TY= 1/ 20:REM  1/20-YEAR STEPS
5000 REM  --- JOURNEY TO NEMO
5020 GOSUB 25000
5040 POKE 33278,0
5050 ES= ES+ TS:EY= EY+ TY
5100 GOSUB 26000
5110 GOSUB 20000
5200 IF (C(9)+ .001)> NLTHEN 6000:REM  REACHED NEMO YET?
5900 FOR Z= 1TO 500:NEXT Z
5910 IF PEEK (33278)= 0THEN 5040
5920 GOSUB 24000
5930 GOTO 5020
6000 REM  --- LAND ON NEMO
6010 AR= 0:AG= 0:C(6)= 127:C(7)= 0:C(10)= 0:DN= 0
6015 C(9)= NL:C(8)= NL* KY
6020 GOSUB 20000:GOSUB 22000
6030 PRINT "YOU ARE IN ORBIT AROUND NEMO.  WAIT FOR AUTOMATIC LANDING..."
6050 FOR Z= 1TO 4000:NEXT Z
6060 C(6)= 0
6070 GOSUB 20000:GOSUB 22000
6080 PRINT "WELCOME TO NEMO!  WEATHER REPORT: TEMP. 17 C; WINDS 23 KM/HR."
6090 PRINT "THE NATIVES ARE CRAWLING ALL OVER YOUR SPACE SHIP."
6100 PLOT 6,1,3,0,31,11
6110 INPUT "DO YOU WANT TO END YOUR JOURNEY, OR RETURN TO EARTH? ";Q$
6120 IF LEFT$ (Q$,1)= "E"THEN 19000
7000 REM  --- LEAVE NEMO
7010 DF= - 1:GOSUB 22000
7020 PRINT "NEMO HAS VERY LITTLE GRAVITY, THEREFORE YOU CAN ACCELERATE"
7030 PRINT "DIRECTLY TOWARD EARTH."
7040 PLOT 6,1,3,0,31,11
7050 INPUT "ENTER LIFTOFF ACCELERATION (5 TO 30): ";X
7060 IF X< 5OR X> 30THEN 7040
7100 AR= X:AG= AR/ GE:GS= AR/ C2
7130 GOSUB 28000:GOSUB 22000
7140 PRINT "PRESS <HOME> TO CHANGE ACCELERATION."
8000 REM  --- JOURNEY TO EARTH
8020 GOSUB 25000
8040 POKE 33278,0
8050 ES= ES+ TS:EY= EY+ TY
8100 GOSUB 26000
8110 GOSUB 20000
8200 IF C(9)< .001THEN 9000:REM  REACHED EARTH YET?
8900 FOR Z= 1TO 500:NEXT Z
8910 IF PEEK (33278)= 0THEN 8040
8920 GOSUB 24000
8930 GOTO 8020
9000 REM  --- LAND ON EARTH
9010 AR= 0:AG= 0:C(6)= 7400:C(7)= 0:C(10)= 0:DN= 0
9015 C(9)= 0:C(8)= 217
9020 GOSUB 20000:GOSUB 22000
9030 PRINT "YOU ARE IN ORBIT AROUND EARTH.  WAIT FOR AUTOMATIC LANDING..."
9050 FOR Z= 1TO 4000:NEXT Z
9060 C(6)= 0:C(8)= 0
9070 GOSUB 20000:GOSUB 22000
9080 PRINT "WELCOME BACK TO EARTH!  WEATHER REPORT: TEMP. 22 C."
9090 X= C(5)
9100 IF X> 94THEN PRINT "YOUR TWIN DIED";X- 93;" YEARS AGO.":GOTO 9200
9110 IF X> 85THEN PRINT "YOUR TWIN IS NOW IN THE LAKEVIEW NURSING HOME.":GOTO 9200
9120 IF X> 62THEN PRINT "YOUR ELDERLY TWIN IS NOW LIVING ON SOCIAL SECURITY!":GOTO 9200
9130 PRINT "YOUR TWIN AWAITS YOU IN THE LOBBY!"
9200 PLOT 6,1,3,0,31
9210 INPUT "ANOTHER JOURNEY? (Y OR N): ";Q$
9220 IF Q$= "Y"THEN 2000
19000 REM  --- END OF PROGRAM
19990 PLOT 6,3,15,27,11,3,0,26:END
19999 REM  --- SUBROUTINES FOLLOW ---
20000 REM  --- UPDATE DISPLAY
20010 REM  FLIGHT PATH
20020 PLOT 6,3,3,2,2:PRINT S$;S$;S$;S$
20030 RP= INT (C(9)/ NL* 59+ 2.5):REM  ROCKET PLOT POSITION
20040 A$= ">":IF DF= - 1THEN A$= "<"
20050 IF RP< 2OR RP> 61THEN 20300
20060 PLOT 3,RP,2:PRINT A$
20300 REM  STATUS BOARD
20310 REM  X=37; Y=10 TO 25
20320 PLOT 6,6
20325 PLOT 3,37,10:PRINT S$
20330 PLOT 3,37,10:PRINT AR
20335 PLOT 3,37,11:PRINT S$
20340 PLOT 3,37,11:PRINT AG
20400 FOR J= 0TO 9
20405 PLOT 3,37,J+ 12:PRINT S$
20410 PLOT 3,37,J+ 12:PRINT C(J)
20420 NEXT J
20590 PLOT 3,37,23:PRINT S$
20600 PLOT 3,37,23:PRINT DN
20610 PLOT 3,0,27
20700 RETURN
22000 REM  --- ERASE MESSAGE AREA
22010 PLOT 3,0,27,11,10,11,10,11,10,11,10,11
22020 PLOT 3,0,28,6,3:RETURN
24000 REM  --- CHANGE ACCELERATION
24010 GOSUB 22000
24020 PRINT "ENTER THE NEW ACCELERATION.  POSITIVE TO SPEED UP;"
24030 PRINT "ZERO TO COAST; NEGATIVE TO SLOW DOWN."
24040 PLOT 6,1,3,0,31,11
24050 INPUT "ENTER NEW ACCELERATION IN M/S/S (-30 TO +30): ";X
24060 IF X< - 30OR X> 30THEN 24040
24070 AR= X:AG= AR/ GE
24080 GS= AR/ C2
24090 GOSUB 22000
24100 PRINT "PRESS <HOME> TO CHANGE THE ACCELERATION."
24200 RETURN
25000 REM  --- BEGIN NEW ACCELERATION
25010 FOR J= 0TO 10:B(J)= C(J):NEXT J
25020 ES= 0:EY= 0
25030 RETURN
26000 REM  --- CALC NEW C(J) VALUES
26030 TA= ES* C1:REM  TAU (TIME IN METRES)
26040 TH= GS* TA:REM  DELTA THETA (DIMENSIONLESS)
26100 REM     ROCKET TIME
26120 C(0)= B(0)+ ES
26140 C(1)= B(1)+ EY
26150 C(4)= B(4)+ EY
26180 REM     EARTH TIME (TWO CASES: AR=0 OR AR<>0)
26200 IF AR= 0THEN X2= ES/ SQR (1- B(7)* B(7)):REM  LORENTZ EQ.
26220 IF AR< > 0THEN X2= FN B2(TH)* ES
26250 C(2)= B(2)+ X2
26260 C(3)= C(2)/ SY
26270 C(5)= A(5)+ C(3)
26300 REM     VELOCITY
26320 C(10)= B(10)+ TH
26340 C(7)= FN B3(C(10))
26360 C(6)= C(7)* C1
26400 REM     DISTANCE FROM EARTH
26420 IF GS< > 0THEN X1= (FN B2(C(10))- FN B2(B(10)))/ GS
26430 IF GS= 0THEN X1= B(6)* X2
26470 C(8)= B(8)+ DF* X1/ 1000
26480 C(9)= C(8)/ KY
26700 REM     DECEL. NEEDED
26710 IF DF= 1THEN X3= (NL- C(9))* MY
26720 IF DF= - 1THEN X3= C(9)* MY:REM  METRES TO GO
26740 IF X3= 0THEN DN= 0:GOTO 26770
26750 DN= (FN B2(C(10))- 1)* C2/ X3
26770 IF C(7)* B(7)< 0THEN GOSUB 25000:REM  CHANGE IN SIGN OF V?
26900 RETURN
28000 REM  --- COUNTDOWN
28010 GOSUB 22000
28020 PRINT "STAND BY FOR ENGINE IGNITION..."
28030 FOR X= 10TO 0STEP - 1
28040 FOR Z= 1TO 500:NEXT Z
28050 PLOT 6,1,3,30,31:PRINT X;" ":NEXT X
28060 RETURN
28070 END